Skip to content

PD

momapy.sbgn.pd

Classes:

Name Description
AndOperator

Class for and operators

AndOperatorLayout

Class for and operator layouts

Association

Class for associations

AssociationLayout

Class for association layouts

CardinalityLayout

Class for cardinality layouts

Catalysis

Class for catalyses

CatalysisLayout

Class for catalysis layouts

Compartment

Class for compartments

CompartmentLayout

Class for compartment layouts

Complex

Class for complexes

ComplexLayout

Class for complex layouts

ComplexMultimer

Class for complex multimers

ComplexMultimerLayout

Class for complex multimer layouts

ComplexMultimerSubunit

Class for complex subunits

ComplexMultimerSubunitLayout

Class for complex multimer subunit layouts

ComplexSubunit

Class for complex subunits

ComplexSubunitLayout

Class for complex subunit layouts

ConsumptionLayout

Class for consumption layouts

Dissociation

Class for dissociations

DissociationLayout

Class for dissociation layouts

EmptySet

Class for empty sets

EmptySetLayout

Class for empty set layouts

EntityPool

Base class for entity pools

EquivalenceArcLayout

Class for equivalence arc layouts

EquivalenceOperator

Class for equivalence operators

EquivalenceOperatorInput

Class for inputs of equivalence operators

EquivalenceOperatorLayout

Class for equivalence operator layouts

EquivalenceOperatorOutput

Class for outputs of equivalence operators

FluxRole

Base class for flux roles

GenericProcess

Class for generic processes

GenericProcessLayout

Class for generic process layouts

Inhibition

Class for inhibitions

InhibitionLayout

Class for inhibition layouts

LogicArcLayout

Class for logic arc layouts

LogicalOperator

Class for logical operators

LogicalOperatorInput

Class for inputs of logical operators

Macromolecule

Class for macromolecules

MacromoleculeLayout

Class for macromolecule layouts

MacromoleculeMultimer

Class for macromolecule multimers

MacromoleculeMultimerLayout

Class for macromolecule multimer layouts

MacromoleculeMultimerSubunit

Class for macromolecule multimer subunits

MacromoleculeMultimerSubunitLayout

Class for macromolecule multimer subunit layouts

MacromoleculeSubunit

Class for macromolecule subunits

MacromoleculeSubunitLayout

Class for macromolecule subunit layouts

Modulation

Class for modulations

ModulationLayout

Class for modulation layouts

Multimer

Base class for multimers

MultimerSubunit

Base class for multimer subunits

NecessaryStimulation

Class for necessary stimulations

NecessaryStimulationLayout

Class for necessary stimulation layouts

NotOperator

Class for not operators

NotOperatorLayout

Class for not operator layouts

NucleicAcidFeature

Class for nucleic acid features

NucleicAcidFeatureLayout

Class for nucleic acid feature layouts

NucleicAcidFeatureMultimer

Class for nucleic acid feature multimers

NucleicAcidFeatureMultimerLayout

Class for nucleic acid feature multimer layouts

NucleicAcidFeatureMultimerSubunit

Class for nucleic acid feature multimer subunits

NucleicAcidFeatureMultimerSubunitLayout

Class for nucleic acid feature multimer subunit layouts

NucleicAcidFeatureSubunit

Class for nucleic acid feature subunits

NucleicAcidFeatureSubunitLayout

Class for nucleic acid feature subunit layouts

OmittedProcess

Class for omitted processes

OmittedProcessLayout

Class for omitted process layouts

OrOperator

Class for or operators

OrOperatorLayout

Class for or operator layouts

PerturbingAgent

Class for perturbing agents

PerturbingAgentLayout

Class for perturbing agent layouts

Phenotype

Class for phenotypes

PhenotypeLayout

Class for phenotype layouts

Process

Base class for processes

Product

Class for products

ProductionLayout

Class for production layouts

Reactant

Class for reactants

SBGNPDLayout

Class for SBGN-PD layouts

SBGNPDMap

Class for SBGN-PD maps

SBGNPDModel

Class for SBGN-PD models

SimpleChemical

Class for simple chemical

SimpleChemicalLayout

Class for simple chemical layouts

SimpleChemicalMultimer

Class for simple chemical multimers

SimpleChemicalMultimerLayout

Class for simple chemical multimer layouts

SimpleChemicalMultimerSubunit

Class for simple chemical multimer subunits

SimpleChemicalMultimerSubunitLayout

Class for simple chemical multimer subunit layouts

SimpleChemicalSubunit

Class for simple chemical subunits

SimpleChemicalSubunitLayout

Class for simple chemical subunit layouts

StateVariable

Class for state variables

StateVariableLayout

Class for state variable layouts

Stimulation

Class for stimulations

StimulationLayout

Class for stimulation layouts

StoichiometricProcess

Base class for stoichiometric processes

Submap

Class for submaps

SubmapLayout

Class for submap layouts

Subunit

Base class for subunits

Tag

Class for tags

TagLayout

Class for tag layouts

TagReference

Class for tag references

Terminal

Class for terminals

TerminalLayout

Class for terminal layouts

TerminalReference

Class for terminal references

UncertainProcess

Class for uncertain processes

UncertainProcessLayout

Class for uncertain process layouts

UnitOfInformation

Class for units of information

UnitOfInformationLayout

Class for unit of information layouts

UnspecifiedEntity

Class for unspecified entities

UnspecifiedEntityLayout

Class for unspecified entity layouts

UnspecifiedEntitySubunit

Class for unspecified entity subunits

UnspecifiedEntitySubunitLayout

Class for unspecified entity subunit layouts

Attributes:

Name Type Description
SBGNPDLayoutBuilder

Class for SBGN-PD layout builders

SBGNPDMapBuilder

Class for SBGN-PD map builders

SBGNPDModelBuilder

Class for SBGN-PD model builders

AndOperator dataclass

AndOperator(
    *,
    id_: str = get_uuid4_as_str(),
    inputs: frozenset[LogicalOperatorInput] = frozenset()
)

Bases: LogicalOperator

Class for and operators

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'7d28b4d6-06c8-4352-9c1a-c68bca8a9f8c'

AndOperatorLayout dataclass

AndOperatorLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 30.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 30.0,
    direction: Direction = HORIZONTAL,
    left_to_right: bool = True,
    left_connector_length: float = 10.0,
    right_connector_length: float = 10.0,
    left_connector_stroke: (
        NoneValueType | Color | None
    ) = None,
    left_connector_stroke_width: float | None = None,
    left_connector_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    left_connector_stroke_dashoffset: float | None = None,
    left_connector_fill: (
        NoneValueType | Color | None
    ) = None,
    left_connector_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    left_connector_filter: (
        NoneValueType | Filter | None
    ) = None,
    right_connector_stroke: (
        NoneValueType | Color | None
    ) = None,
    right_connector_stroke_width: float | None = None,
    right_connector_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    right_connector_stroke_dashoffset: float | None = None,
    right_connector_fill: (
        NoneValueType | Color | None
    ) = None,
    right_connector_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    right_connector_filter: (
        NoneValueType | Filter | None
    ) = None
)

Bases: _ConnectorsMixin, _SimpleMixin, _TextMixin, SBGNNode

Class for and operator layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'092140f1-d606-49ee-bf93-db3056701771'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
30.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
30.0
direction Direction
<Direction.HORIZONTAL: 1>
left_to_right bool
True
left_connector_length float
10.0
right_connector_length float
10.0
left_connector_stroke NoneValueType | Color | None
None
left_connector_stroke_width float | None
None
left_connector_stroke_dasharray NoneValueType | tuple[float] | None
None
left_connector_stroke_dashoffset float | None
None
left_connector_fill NoneValueType | Color | None
None
left_connector_transform NoneValueType | tuple[Transformation] | None
None
left_connector_filter NoneValueType | Filter | None
None
right_connector_stroke NoneValueType | Color | None
None
right_connector_stroke_width float | None
None
right_connector_stroke_dasharray NoneValueType | tuple[float] | None
None
right_connector_stroke_dashoffset float | None
None
right_connector_fill NoneValueType | Color | None
None
right_connector_transform NoneValueType | tuple[Transformation] | None
None
right_connector_filter NoneValueType | Filter | None
None

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
791
792
793
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

Association dataclass

Association(
    *,
    id_: str = get_uuid4_as_str(),
    reactants: frozenset[Reactant] = frozenset(),
    products: frozenset[Product] = frozenset(),
    reversible: bool = False
)

Bases: GenericProcess

Class for associations

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'50b13b0f-b89e-48bb-8ef4-2140afe8963a'
reversible bool
False

AssociationLayout dataclass

AssociationLayout(
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    fill: NoneValueType | Color | None = black,
    filter: NoneValueType | Filter | None = None,
    height: float = 20.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 20.0,
    direction: Direction = HORIZONTAL,
    left_to_right: bool = True,
    left_connector_length: float = 10.0,
    right_connector_length: float = 10.0,
    left_connector_stroke: (
        NoneValueType | Color | None
    ) = None,
    left_connector_stroke_width: float | None = None,
    left_connector_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    left_connector_stroke_dashoffset: float | None = None,
    left_connector_fill: (
        NoneValueType | Color | None
    ) = None,
    left_connector_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    left_connector_filter: (
        NoneValueType | Filter | None
    ) = None,
    right_connector_stroke: (
        NoneValueType | Color | None
    ) = None,
    right_connector_stroke_width: float | None = None,
    right_connector_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    right_connector_stroke_dashoffset: float | None = None,
    right_connector_fill: (
        NoneValueType | Color | None
    ) = None,
    right_connector_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    right_connector_filter: (
        NoneValueType | Filter | None
    ) = None
)

Bases: _ConnectorsMixin, _SimpleMixin, SBGNNode

Class for association layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'104f50e9-d889-497b-839e-2f1c8d732791'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
20.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
20.0
direction Direction
<Direction.HORIZONTAL: 1>
left_to_right bool
True
left_connector_length float
10.0
right_connector_length float
10.0
left_connector_stroke NoneValueType | Color | None
None
left_connector_stroke_width float | None
None
left_connector_stroke_dasharray NoneValueType | tuple[float] | None
None
left_connector_stroke_dashoffset float | None
None
left_connector_fill NoneValueType | Color | None
None
left_connector_transform NoneValueType | tuple[Transformation] | None
None
left_connector_filter NoneValueType | Filter | None
None
right_connector_stroke NoneValueType | Color | None
None
right_connector_stroke_width float | None
None
right_connector_stroke_dasharray NoneValueType | tuple[float] | None
None
right_connector_stroke_dashoffset float | None
None
right_connector_fill NoneValueType | Color | None
None
right_connector_transform NoneValueType | tuple[Transformation] | None
None
right_connector_filter NoneValueType | Filter | None
None

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
791
792
793
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

CardinalityLayout dataclass

CardinalityLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 19.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 12.0
)

Bases: _SimpleMixin, SBGNNode

Class for cardinality layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'7bf5f910-f1da-47a1-a660-571bdce338fd'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
19.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
12.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
791
792
793
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

Catalysis dataclass

Catalysis(
    *,
    id_: str = get_uuid4_as_str(),
    source: EntityPool | LogicalOperator,
    target: Process
)

Bases: Stimulation

Class for catalyses

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'fdf477d5-0f80-4787-b284-65ac2076a3e1'
source EntityPool | LogicalOperator
required
target Process
required

CatalysisLayout dataclass

CatalysisLayout(
    path_fill: NoneValueType | Color | None = NoneValue,
    path_stroke: NoneValueType | Color | None = black,
    path_stroke_width: float | None = 1.25,
    arrowhead_fill: NoneValueType | Color | None = white,
    arrowhead_stroke: NoneValueType | Color | None = black,
    arrowhead_stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_shorten: float = 0.0,
    fill: NoneValueType | Color | None = None,
    filter: NoneValueType | Filter | None = None,
    path_filter: NoneValueType | Filter | None = None,
    path_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    path_stroke_dashoffset: float | None = None,
    path_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    stroke: NoneValueType | Color | None = None,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    stroke_width: float | None = None,
    segments: tuple[
        Segment | BezierCurve | EllipticalArc
    ] = tuple(),
    source: LayoutElement | None = None,
    start_shorten: float = 0.0,
    target: LayoutElement | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    arrowhead_filter: NoneValueType | Filter | None = None,
    arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    arrowhead_stroke_dashoffset: float | None = None,
    arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    arrowhead_height: float = 10.0,
    arrowhead_width: float = 10.0
)

Bases: SBGNSingleHeadedArc

Class for catalysis layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'83dcf0eb-98b0-4329-8e4e-b09a02d83248'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
end_shorten float

The length the end of the arc will be shorten by

0.0
fill NoneValueType | Color | None

The fill color of the arc

None
filter NoneValueType | Filter | None

The fill filter of the arc

None
path_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
path_filter NoneValueType | Filter | None

The path filter of the arc

None
path_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
path_stroke_dasharray NoneValueType | tuple[float] | None

The path stroke dasharray of the arc

None
path_stroke_dashoffset float | None

The path stroke dashoffset of the arc

None
path_stroke_width float | None
1.25
path_transform NoneValueType | tuple[Transformation] | None

The path transform of the arc

None
stroke NoneValueType | Color | None

The stroke color of the arc

None
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the arc

None
stroke_dashoffset float | None

The stroke dashoffset of the arc

None
stroke_width float | None

The stroke width of the arc

None
segments tuple[Union[Segment, BezierCurve, EllipticalArc]]

The path segments of the arc

<dynamic>
source LayoutElement | None

The source of the arc

None
start_shorten float

The length the start of the arc will be shorten by

0.0
target LayoutElement | None

The target of the arc

None
transform NoneValueType | tuple[Transformation] | None

The transform of the arc

None
arrowhead_fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
arrowhead_filter NoneValueType | Filter | None

The arrowhead filter of the arc

None
arrowhead_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
arrowhead_stroke_dasharray NoneValueType | tuple[float] | None

The arrowhead stroke dasharray of the arc

None
arrowhead_stroke_dashoffset float | None

The arrowhead stroke dashoffset of the arc

None
arrowhead_stroke_width float | None
1.25
arrowhead_transform NoneValueType | tuple[Transformation] | None

The arrowhead transform of the arc

None
arrowhead_height float
10.0
arrowhead_width float
10.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

arrowhead_base

Return the arrowhead base anchor point of the single-headed arc

arrowhead_bbox

Return the bounding box of the single-headed arc arrowhead

arrowhead_border

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.

arrowhead_drawing_elements

Return the drawing elements of the single-headed arc arrowhead

arrowhead_length

Return the length of the single-headed arc arrowhead

arrowhead_tip

Return the arrowhead tip anchor point of the single-headed arc

bbox

Compute and return the bounding box of the layout element

childless

Return a copy of the arc with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

end_point

Return the ending point of the arc

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

fraction

Return the position and angle on the arc at a given fraction (of the total arc length)

length

Return the total length of the arc path

path_drawing_elements

Return the drawing elements of the single-headed arc path

points

Return the points of the arc path

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_children

Return the self children of the arc

self_drawing_elements

Return the self drawing elements of the single-headed arc

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

start_point

Return the starting point of the arc

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

arrowhead_base

arrowhead_base() -> Point

Return the arrowhead base anchor point of the single-headed arc

Source code in src/momapy/core.py
1089
1090
1091
1092
1093
1094
1095
1096
1097
def arrowhead_base(self) -> momapy.geometry.Point:
    """Return the arrowhead base anchor point of the single-headed arc"""
    arrowhead_length = self.arrowhead_length()
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return self.arrowhead_tip() - (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.end_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

arrowhead_bbox

arrowhead_bbox() -> Bbox

Return the bounding box of the single-headed arc arrowhead

Source code in src/momapy/core.py
1099
1100
1101
1102
1103
def arrowhead_bbox(self) -> momapy.geometry.Bbox:
    """Return the bounding box of the single-headed arc arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.arrowhead_drawing_elements()
    )

arrowhead_border

arrowhead_border(point) -> Point

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
def arrowhead_border(self, point) -> momapy.geometry.Point:
    """Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """

    point = momapy.drawing.get_drawing_elements_border(
        self.arrowhead_drawing_elements(), point
    )
    if point is None:
        return self.arrowhead_tip()
    return point

arrowhead_drawing_elements

arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the single-headed arc arrowhead

Source code in src/momapy/core.py
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
def arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the single-headed arc arrowhead"""
    elements = self._arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_arrowhead",
        elements=elements,
        fill=self.arrowhead_fill,
        filter=self.arrowhead_filter,
        id_=f"{self.id_}_arrowhead",
        stroke=self.arrowhead_stroke,
        stroke_dasharray=self.arrowhead_stroke_dasharray,
        stroke_dashoffset=self.arrowhead_stroke_dashoffset,
        stroke_width=self.arrowhead_stroke_width,
        transform=self.arrowhead_transform,
    )
    transformation = self._get_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

arrowhead_length

arrowhead_length() -> float

Return the length of the single-headed arc arrowhead

Source code in src/momapy/core.py
1071
1072
1073
1074
1075
1076
1077
1078
def arrowhead_length(self) -> float:
    """Return the length of the single-headed arc arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return bbox.east().x

arrowhead_tip

arrowhead_tip() -> Point

Return the arrowhead tip anchor point of the single-headed arc

Source code in src/momapy/core.py
1080
1081
1082
1083
1084
1085
1086
1087
def arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the arrowhead tip anchor point of the single-headed arc"""
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.end_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

childless

childless() -> Self

Return a copy of the arc with no children

Source code in src/momapy/core.py
978
979
980
def childless(self) -> typing.Self:
    """Return a copy of the arc with no children"""
    return dataclasses.replace(self, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

end_point

end_point() -> Point

Return the ending point of the arc

Source code in src/momapy/core.py
974
975
976
def end_point(self) -> momapy.geometry.Point:
    """Return the ending point of the arc"""
    return self.points()[-1]

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

fraction

fraction(fraction: float) -> tuple[Point, float]

Return the position and angle on the arc at a given fraction (of the total arc length)

Source code in src/momapy/core.py
982
983
984
985
986
987
988
989
990
991
def fraction(self, fraction: float) -> tuple[momapy.geometry.Point, float]:
    """Return the position and angle on the arc at a given fraction (of the total arc length)"""
    current_length = 0
    length_to_reach = fraction * self.length()
    for segment in self.segments:
        current_length += segment.length()
        if current_length >= length_to_reach:
            break
    position, angle = segment.get_position_and_angle_at_fraction(fraction)
    return position, angle

length

length()

Return the total length of the arc path

Source code in src/momapy/core.py
966
967
968
def length(self):
    """Return the total length of the arc path"""
    return sum([segment.length() for segment in self.segments])

path_drawing_elements

path_drawing_elements() -> list[Path]

Return the drawing elements of the single-headed arc path

Source code in src/momapy/core.py
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
def path_drawing_elements(self) -> list[momapy.drawing.Path]:
    """Return the drawing elements of the single-headed arc path"""
    arrowhead_length = self.arrowhead_length()
    if len(self.segments) == 1:
        segment = (
            self.segments[0]
            .shortened(self.start_shorten, "start")
            .shortened(self.end_shorten + arrowhead_length, "end")
        )
        actions = [
            momapy.drawing.MoveTo(segment.p1),
            self._make_path_action_from_segment(segment),
        ]
    else:
        first_segment = self.segments[0].shortened(
            self.start_shorten, "start"
        )
        last_segment = self.segments[-1].shortened(
            self.end_shorten + arrowhead_length, "end"
        )
        actions = [
            momapy.drawing.MoveTo(first_segment.p1),
            self._make_path_action_from_segment(first_segment),
        ]
        for segment in self.segments[1:-1]:
            action = self._make_path_action_from_segment(segment)
            actions.append(action)
        actions.append(self._make_path_action_from_segment(last_segment))
    path = momapy.drawing.Path(
        actions=actions,
        class_=f"{type(self).__name__}_path",
        fill=self.path_fill,
        filter=self.path_filter,
        id_=f"{self.id_}_path",
        stroke=self.path_stroke,
        stroke_dasharray=self.path_stroke_dasharray,
        stroke_dashoffset=self.path_stroke_dashoffset,
        stroke_width=self.path_stroke_width,
        transform=self.path_transform,
    )
    return [path]

points

points() -> list[Point]

Return the points of the arc path

Source code in src/momapy/core.py
958
959
960
961
962
963
964
def points(self) -> list[momapy.geometry.Point]:
    """Return the points of the arc path"""
    points = []
    for segment in self.segments:
        points.append(segment.p1)
    points.append(segment.p2)
    return points

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_children

self_children() -> list[LayoutElement]

Return the self children of the arc

Source code in src/momapy/core.py
954
955
956
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the arc"""
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the single-headed arc

Source code in src/momapy/core.py
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the single-headed arc"""
    elements = (
        self.path_drawing_elements() + self.arrowhead_drawing_elements()
    )
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

start_point

start_point() -> Point

Return the starting point of the arc

Source code in src/momapy/core.py
970
971
972
def start_point(self) -> momapy.geometry.Point:
    """Return the starting point of the arc"""
    return self.points()[0]

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

Compartment dataclass

Compartment(
    *,
    id_: str = get_uuid4_as_str(),
    label: str | None = None,
    state_variables: frozenset[StateVariable] = frozenset(),
    units_of_information: frozenset[
        UnitOfInformation
    ] = frozenset()
)

Bases: SBGNModelElement

Class for compartments

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'639ded38-cfeb-48aa-8e68-18e49a3fa508'
label str | None
None

CompartmentLayout dataclass

CompartmentLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 80.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    stroke_width: float = 3.25,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 80.0,
    rounded_corners: float = 5.0
)

Bases: _SimpleMixin, SBGNNode

Class for compartment layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'8a67ae85-87df-4f92-b2e7-cf4f53cdfd4e'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
80.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float
3.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
80.0
rounded_corners float
5.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
791
792
793
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

Complex dataclass

Complex(
    *,
    id_: str = get_uuid4_as_str(),
    compartment: Compartment | None = None,
    label: str | None = None,
    state_variables: frozenset[StateVariable] = frozenset(),
    units_of_information: frozenset[
        UnitOfInformation
    ] = frozenset(),
    subunits: frozenset[Subunit] = frozenset()
)

Bases: EntityPool

Class for complexes

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'56d51f68-4c00-4951-b54d-b5d3efa82cf0'
compartment Compartment | None
None
label str | None
None

ComplexLayout dataclass

ComplexLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 44.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 44.0,
    cut_corners: float = 5.0
)

Bases: _SimpleMixin, SBGNNode

Class for complex layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'269ad92a-6c7d-41b9-82dd-55a3b57a2266'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
44.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
44.0
cut_corners float
5.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
791
792
793
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

ComplexMultimer dataclass

ComplexMultimer(
    *,
    id_: str = get_uuid4_as_str(),
    compartment: Compartment | None = None,
    label: str | None = None,
    state_variables: frozenset[StateVariable] = frozenset(),
    units_of_information: frozenset[
        UnitOfInformation
    ] = frozenset(),
    subunits: frozenset[Subunit] = frozenset(),
    cardinality: int | None = None
)

Bases: Multimer

Class for complex multimers

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'bf04663a-fecb-47c5-b229-72be84e9ec1b'
compartment Compartment | None
None
label str | None
None
cardinality int | None
None

ComplexMultimerLayout dataclass

ComplexMultimerLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    offset: float = 3.0,
    subunits_stroke: (
        tuple[NoneValueType | Color] | None
    ) = None,
    subunits_stroke_width: (
        tuple[NoneValueType | float] | None
    ) = None,
    subunits_stroke_dasharray: (
        tuple[NoneValueType | tuple[float]] | None
    ) = None,
    subunits_stroke_dashoffset: tuple[float] | None = None,
    subunits_fill: (
        tuple[NoneValueType | Color] | None
    ) = None,
    subunits_transform: (
        tuple[NoneValueType | tuple[Transformation]] | None
    ) = None,
    subunits_filter: (
        tuple[NoneValueType | Filter] | None
    ) = None,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 44.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 44.0,
    cut_corners: float = 5.0
)

Bases: _MultiMixin, SBGNNode

Class for complex multimer layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'add150dd-d267-4c7e-a8ae-f27f232e483d'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
44.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
44.0
offset float
3.0
subunits_stroke tuple[Union[NoneValueType, Color]] | None
None
subunits_stroke_width tuple[Union[NoneValueType, float]] | None
None
subunits_stroke_dasharray tuple[Union[NoneValueType, tuple[float]]] | None
None
subunits_stroke_dashoffset tuple[float] | None
None
subunits_fill tuple[Union[NoneValueType, Color]] | None
None
subunits_transform tuple[Union[NoneValueType, tuple[Transformation]]] | None
None
subunits_filter tuple[Union[NoneValueType, Filter]] | None
None
cut_corners float
5.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

ComplexMultimerSubunit dataclass

ComplexMultimerSubunit(
    *,
    id_: str = get_uuid4_as_str(),
    label: str | None = None,
    state_variables: frozenset[StateVariable] = frozenset(),
    units_of_information: frozenset[
        UnitOfInformation
    ] = frozenset(),
    subunits: frozenset[Subunit] = frozenset(),
    cardinality: int | None = None
)

Bases: MultimerSubunit

Class for complex subunits

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'4cf4d117-b711-4743-9964-9a674e49e2c6'
label str | None
None
cardinality int | None
None

ComplexMultimerSubunitLayout dataclass

ComplexMultimerSubunitLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    offset: float = 3.0,
    subunits_stroke: (
        tuple[NoneValueType | Color] | None
    ) = None,
    subunits_stroke_width: (
        tuple[NoneValueType | float] | None
    ) = None,
    subunits_stroke_dasharray: (
        tuple[NoneValueType | tuple[float]] | None
    ) = None,
    subunits_stroke_dashoffset: tuple[float] | None = None,
    subunits_fill: (
        tuple[NoneValueType | Color] | None
    ) = None,
    subunits_transform: (
        tuple[NoneValueType | tuple[Transformation]] | None
    ) = None,
    subunits_filter: (
        tuple[NoneValueType | Filter] | None
    ) = None,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 30.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 60.0,
    cut_corners: float = 5.0
)

Bases: _MultiMixin, SBGNNode

Class for complex multimer subunit layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'ed28b093-01c3-4f62-82ce-a384ef7c58fe'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
30.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
60.0
offset float
3.0
subunits_stroke tuple[Union[NoneValueType, Color]] | None
None
subunits_stroke_width tuple[Union[NoneValueType, float]] | None
None
subunits_stroke_dasharray tuple[Union[NoneValueType, tuple[float]]] | None
None
subunits_stroke_dashoffset tuple[float] | None
None
subunits_fill tuple[Union[NoneValueType, Color]] | None
None
subunits_transform tuple[Union[NoneValueType, tuple[Transformation]]] | None
None
subunits_filter tuple[Union[NoneValueType, Filter]] | None
None
cut_corners float
5.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

ComplexSubunit dataclass

ComplexSubunit(
    *,
    id_: str = get_uuid4_as_str(),
    label: str | None = None,
    state_variables: frozenset[StateVariable] = frozenset(),
    units_of_information: frozenset[
        UnitOfInformation
    ] = frozenset(),
    subunits: frozenset[Subunit] = frozenset()
)

Bases: Subunit

Class for complex subunits

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'32c40c61-954f-456b-b295-29de6a9887e7'
label str | None
None

ComplexSubunitLayout dataclass

ComplexSubunitLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 30.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 60.0,
    cut_corners: float = 5.0
)

Bases: _SimpleMixin, SBGNNode

Class for complex subunit layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'5f351a2b-e5cc-456f-b365-b07b06634ccb'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
30.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
60.0
cut_corners float
5.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
791
792
793
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

ConsumptionLayout dataclass

ConsumptionLayout(
    path_fill: NoneValueType | Color | None = NoneValue,
    path_stroke: NoneValueType | Color | None = black,
    path_stroke_width: float | None = 1.25,
    arrowhead_fill: NoneValueType | Color | None = white,
    arrowhead_stroke: NoneValueType | Color | None = black,
    arrowhead_stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_shorten: float = 0.0,
    fill: NoneValueType | Color | None = None,
    filter: NoneValueType | Filter | None = None,
    path_filter: NoneValueType | Filter | None = None,
    path_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    path_stroke_dashoffset: float | None = None,
    path_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    stroke: NoneValueType | Color | None = None,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    stroke_width: float | None = None,
    segments: tuple[
        Segment | BezierCurve | EllipticalArc
    ] = tuple(),
    source: LayoutElement | None = None,
    start_shorten: float = 0.0,
    target: LayoutElement | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    arrowhead_filter: NoneValueType | Filter | None = None,
    arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    arrowhead_stroke_dashoffset: float | None = None,
    arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None
)

Bases: SBGNSingleHeadedArc

Class for consumption layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'd795cd71-8be1-4328-912c-c83970ff3bf8'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
end_shorten float

The length the end of the arc will be shorten by

0.0
fill NoneValueType | Color | None

The fill color of the arc

None
filter NoneValueType | Filter | None

The fill filter of the arc

None
path_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
path_filter NoneValueType | Filter | None

The path filter of the arc

None
path_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
path_stroke_dasharray NoneValueType | tuple[float] | None

The path stroke dasharray of the arc

None
path_stroke_dashoffset float | None

The path stroke dashoffset of the arc

None
path_stroke_width float | None
1.25
path_transform NoneValueType | tuple[Transformation] | None

The path transform of the arc

None
stroke NoneValueType | Color | None

The stroke color of the arc

None
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the arc

None
stroke_dashoffset float | None

The stroke dashoffset of the arc

None
stroke_width float | None

The stroke width of the arc

None
segments tuple[Union[Segment, BezierCurve, EllipticalArc]]

The path segments of the arc

<dynamic>
source LayoutElement | None

The source of the arc

None
start_shorten float

The length the start of the arc will be shorten by

0.0
target LayoutElement | None

The target of the arc

None
transform NoneValueType | tuple[Transformation] | None

The transform of the arc

None
arrowhead_fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
arrowhead_filter NoneValueType | Filter | None

The arrowhead filter of the arc

None
arrowhead_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
arrowhead_stroke_dasharray NoneValueType | tuple[float] | None

The arrowhead stroke dasharray of the arc

None
arrowhead_stroke_dashoffset float | None

The arrowhead stroke dashoffset of the arc

None
arrowhead_stroke_width float | None
1.25
arrowhead_transform NoneValueType | tuple[Transformation] | None

The arrowhead transform of the arc

None

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

arrowhead_base

Return the arrowhead base anchor point of the single-headed arc

arrowhead_bbox

Return the bounding box of the single-headed arc arrowhead

arrowhead_border

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.

arrowhead_drawing_elements

Return the drawing elements of the single-headed arc arrowhead

arrowhead_length

Return the length of the single-headed arc arrowhead

arrowhead_tip

Return the arrowhead tip anchor point of the single-headed arc

bbox

Compute and return the bounding box of the layout element

childless

Return a copy of the arc with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

end_point

Return the ending point of the arc

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

fraction

Return the position and angle on the arc at a given fraction (of the total arc length)

length

Return the total length of the arc path

path_drawing_elements

Return the drawing elements of the single-headed arc path

points

Return the points of the arc path

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_children

Return the self children of the arc

self_drawing_elements

Return the self drawing elements of the single-headed arc

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

start_point

Return the starting point of the arc

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

arrowhead_base

arrowhead_base() -> Point

Return the arrowhead base anchor point of the single-headed arc

Source code in src/momapy/core.py
1089
1090
1091
1092
1093
1094
1095
1096
1097
def arrowhead_base(self) -> momapy.geometry.Point:
    """Return the arrowhead base anchor point of the single-headed arc"""
    arrowhead_length = self.arrowhead_length()
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return self.arrowhead_tip() - (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.end_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

arrowhead_bbox

arrowhead_bbox() -> Bbox

Return the bounding box of the single-headed arc arrowhead

Source code in src/momapy/core.py
1099
1100
1101
1102
1103
def arrowhead_bbox(self) -> momapy.geometry.Bbox:
    """Return the bounding box of the single-headed arc arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.arrowhead_drawing_elements()
    )

arrowhead_border

arrowhead_border(point) -> Point

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
def arrowhead_border(self, point) -> momapy.geometry.Point:
    """Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """

    point = momapy.drawing.get_drawing_elements_border(
        self.arrowhead_drawing_elements(), point
    )
    if point is None:
        return self.arrowhead_tip()
    return point

arrowhead_drawing_elements

arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the single-headed arc arrowhead

Source code in src/momapy/core.py
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
def arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the single-headed arc arrowhead"""
    elements = self._arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_arrowhead",
        elements=elements,
        fill=self.arrowhead_fill,
        filter=self.arrowhead_filter,
        id_=f"{self.id_}_arrowhead",
        stroke=self.arrowhead_stroke,
        stroke_dasharray=self.arrowhead_stroke_dasharray,
        stroke_dashoffset=self.arrowhead_stroke_dashoffset,
        stroke_width=self.arrowhead_stroke_width,
        transform=self.arrowhead_transform,
    )
    transformation = self._get_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

arrowhead_length

arrowhead_length() -> float

Return the length of the single-headed arc arrowhead

Source code in src/momapy/core.py
1071
1072
1073
1074
1075
1076
1077
1078
def arrowhead_length(self) -> float:
    """Return the length of the single-headed arc arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return bbox.east().x

arrowhead_tip

arrowhead_tip() -> Point

Return the arrowhead tip anchor point of the single-headed arc

Source code in src/momapy/core.py
1080
1081
1082
1083
1084
1085
1086
1087
def arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the arrowhead tip anchor point of the single-headed arc"""
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.end_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

childless

childless() -> Self

Return a copy of the arc with no children

Source code in src/momapy/core.py
978
979
980
def childless(self) -> typing.Self:
    """Return a copy of the arc with no children"""
    return dataclasses.replace(self, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

end_point

end_point() -> Point

Return the ending point of the arc

Source code in src/momapy/core.py
974
975
976
def end_point(self) -> momapy.geometry.Point:
    """Return the ending point of the arc"""
    return self.points()[-1]

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

fraction

fraction(fraction: float) -> tuple[Point, float]

Return the position and angle on the arc at a given fraction (of the total arc length)

Source code in src/momapy/core.py
982
983
984
985
986
987
988
989
990
991
def fraction(self, fraction: float) -> tuple[momapy.geometry.Point, float]:
    """Return the position and angle on the arc at a given fraction (of the total arc length)"""
    current_length = 0
    length_to_reach = fraction * self.length()
    for segment in self.segments:
        current_length += segment.length()
        if current_length >= length_to_reach:
            break
    position, angle = segment.get_position_and_angle_at_fraction(fraction)
    return position, angle

length

length()

Return the total length of the arc path

Source code in src/momapy/core.py
966
967
968
def length(self):
    """Return the total length of the arc path"""
    return sum([segment.length() for segment in self.segments])

path_drawing_elements

path_drawing_elements() -> list[Path]

Return the drawing elements of the single-headed arc path

Source code in src/momapy/core.py
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
def path_drawing_elements(self) -> list[momapy.drawing.Path]:
    """Return the drawing elements of the single-headed arc path"""
    arrowhead_length = self.arrowhead_length()
    if len(self.segments) == 1:
        segment = (
            self.segments[0]
            .shortened(self.start_shorten, "start")
            .shortened(self.end_shorten + arrowhead_length, "end")
        )
        actions = [
            momapy.drawing.MoveTo(segment.p1),
            self._make_path_action_from_segment(segment),
        ]
    else:
        first_segment = self.segments[0].shortened(
            self.start_shorten, "start"
        )
        last_segment = self.segments[-1].shortened(
            self.end_shorten + arrowhead_length, "end"
        )
        actions = [
            momapy.drawing.MoveTo(first_segment.p1),
            self._make_path_action_from_segment(first_segment),
        ]
        for segment in self.segments[1:-1]:
            action = self._make_path_action_from_segment(segment)
            actions.append(action)
        actions.append(self._make_path_action_from_segment(last_segment))
    path = momapy.drawing.Path(
        actions=actions,
        class_=f"{type(self).__name__}_path",
        fill=self.path_fill,
        filter=self.path_filter,
        id_=f"{self.id_}_path",
        stroke=self.path_stroke,
        stroke_dasharray=self.path_stroke_dasharray,
        stroke_dashoffset=self.path_stroke_dashoffset,
        stroke_width=self.path_stroke_width,
        transform=self.path_transform,
    )
    return [path]

points

points() -> list[Point]

Return the points of the arc path

Source code in src/momapy/core.py
958
959
960
961
962
963
964
def points(self) -> list[momapy.geometry.Point]:
    """Return the points of the arc path"""
    points = []
    for segment in self.segments:
        points.append(segment.p1)
    points.append(segment.p2)
    return points

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_children

self_children() -> list[LayoutElement]

Return the self children of the arc

Source code in src/momapy/core.py
954
955
956
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the arc"""
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the single-headed arc

Source code in src/momapy/core.py
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the single-headed arc"""
    elements = (
        self.path_drawing_elements() + self.arrowhead_drawing_elements()
    )
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

start_point

start_point() -> Point

Return the starting point of the arc

Source code in src/momapy/core.py
970
971
972
def start_point(self) -> momapy.geometry.Point:
    """Return the starting point of the arc"""
    return self.points()[0]

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

Dissociation dataclass

Dissociation(
    *,
    id_: str = get_uuid4_as_str(),
    reactants: frozenset[Reactant] = frozenset(),
    products: frozenset[Product] = frozenset(),
    reversible: bool = False
)

Bases: GenericProcess

Class for dissociations

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'205b8641-3f48-41cb-a97b-04c3af5e447c'
reversible bool
False

DissociationLayout dataclass

DissociationLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 20.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 20.0,
    direction: Direction = HORIZONTAL,
    left_to_right: bool = True,
    left_connector_length: float = 10.0,
    right_connector_length: float = 10.0,
    left_connector_stroke: (
        NoneValueType | Color | None
    ) = None,
    left_connector_stroke_width: float | None = None,
    left_connector_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    left_connector_stroke_dashoffset: float | None = None,
    left_connector_fill: (
        NoneValueType | Color | None
    ) = None,
    left_connector_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    left_connector_filter: (
        NoneValueType | Filter | None
    ) = None,
    right_connector_stroke: (
        NoneValueType | Color | None
    ) = None,
    right_connector_stroke_width: float | None = None,
    right_connector_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    right_connector_stroke_dashoffset: float | None = None,
    right_connector_fill: (
        NoneValueType | Color | None
    ) = None,
    right_connector_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    right_connector_filter: (
        NoneValueType | Filter | None
    ) = None,
    sep: float = 3.0
)

Bases: _ConnectorsMixin, _SimpleMixin, SBGNNode

Class for dissociation layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'53a0873d-d36c-4189-ab2a-92060107a93b'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
20.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
20.0
direction Direction
<Direction.HORIZONTAL: 1>
left_to_right bool
True
left_connector_length float
10.0
right_connector_length float
10.0
left_connector_stroke NoneValueType | Color | None
None
left_connector_stroke_width float | None
None
left_connector_stroke_dasharray NoneValueType | tuple[float] | None
None
left_connector_stroke_dashoffset float | None
None
left_connector_fill NoneValueType | Color | None
None
left_connector_transform NoneValueType | tuple[Transformation] | None
None
left_connector_filter NoneValueType | Filter | None
None
right_connector_stroke NoneValueType | Color | None
None
right_connector_stroke_width float | None
None
right_connector_stroke_dasharray NoneValueType | tuple[float] | None
None
right_connector_stroke_dashoffset float | None
None
right_connector_fill NoneValueType | Color | None
None
right_connector_transform NoneValueType | tuple[Transformation] | None
None
right_connector_filter NoneValueType | Filter | None
None
sep float
3.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
791
792
793
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

EmptySet dataclass

EmptySet(
    *,
    id_: str = get_uuid4_as_str(),
    compartment: Compartment | None = None
)

Bases: EntityPool

Class for empty sets

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'800e7c54-a8d3-42e0-a8f0-49081f36a295'
compartment Compartment | None
None

EmptySetLayout dataclass

EmptySetLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 22.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 22.0
)

Bases: _SimpleMixin, SBGNNode

Class for empty set layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'12de1bd3-7c84-4d98-9977-24e05d6efc67'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
22.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
22.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
791
792
793
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

EntityPool dataclass

EntityPool(
    *,
    id_: str = get_uuid4_as_str(),
    compartment: Compartment | None = None
)

Bases: SBGNModelElement

Base class for entity pools

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'1cbfe59a-01e5-4467-a980-9eb2a716efdd'
compartment Compartment | None
None

EquivalenceArcLayout dataclass

EquivalenceArcLayout(
    path_fill: NoneValueType | Color | None = NoneValue,
    path_stroke: NoneValueType | Color | None = black,
    path_stroke_width: float | None = 1.25,
    arrowhead_fill: NoneValueType | Color | None = white,
    arrowhead_stroke: NoneValueType | Color | None = black,
    arrowhead_stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_shorten: float = 0.0,
    fill: NoneValueType | Color | None = None,
    filter: NoneValueType | Filter | None = None,
    path_filter: NoneValueType | Filter | None = None,
    path_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    path_stroke_dashoffset: float | None = None,
    path_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    stroke: NoneValueType | Color | None = None,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    stroke_width: float | None = None,
    segments: tuple[
        Segment | BezierCurve | EllipticalArc
    ] = tuple(),
    source: LayoutElement | None = None,
    start_shorten: float = 0.0,
    target: LayoutElement | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    arrowhead_filter: NoneValueType | Filter | None = None,
    arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    arrowhead_stroke_dashoffset: float | None = None,
    arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None
)

Bases: SBGNSingleHeadedArc

Class for equivalence arc layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'2fc7ee4a-fb97-4de7-bc25-fb42019790e0'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
end_shorten float

The length the end of the arc will be shorten by

0.0
fill NoneValueType | Color | None

The fill color of the arc

None
filter NoneValueType | Filter | None

The fill filter of the arc

None
path_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
path_filter NoneValueType | Filter | None

The path filter of the arc

None
path_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
path_stroke_dasharray NoneValueType | tuple[float] | None

The path stroke dasharray of the arc

None
path_stroke_dashoffset float | None

The path stroke dashoffset of the arc

None
path_stroke_width float | None
1.25
path_transform NoneValueType | tuple[Transformation] | None

The path transform of the arc

None
stroke NoneValueType | Color | None

The stroke color of the arc

None
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the arc

None
stroke_dashoffset float | None

The stroke dashoffset of the arc

None
stroke_width float | None

The stroke width of the arc

None
segments tuple[Union[Segment, BezierCurve, EllipticalArc]]

The path segments of the arc

<dynamic>
source LayoutElement | None

The source of the arc

None
start_shorten float

The length the start of the arc will be shorten by

0.0
target LayoutElement | None

The target of the arc

None
transform NoneValueType | tuple[Transformation] | None

The transform of the arc

None
arrowhead_fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
arrowhead_filter NoneValueType | Filter | None

The arrowhead filter of the arc

None
arrowhead_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
arrowhead_stroke_dasharray NoneValueType | tuple[float] | None

The arrowhead stroke dasharray of the arc

None
arrowhead_stroke_dashoffset float | None

The arrowhead stroke dashoffset of the arc

None
arrowhead_stroke_width float | None
1.25
arrowhead_transform NoneValueType | tuple[Transformation] | None

The arrowhead transform of the arc

None

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

arrowhead_base

Return the arrowhead base anchor point of the single-headed arc

arrowhead_bbox

Return the bounding box of the single-headed arc arrowhead

arrowhead_border

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.

arrowhead_drawing_elements

Return the drawing elements of the single-headed arc arrowhead

arrowhead_length

Return the length of the single-headed arc arrowhead

arrowhead_tip

Return the arrowhead tip anchor point of the single-headed arc

bbox

Compute and return the bounding box of the layout element

childless

Return a copy of the arc with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

end_point

Return the ending point of the arc

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

fraction

Return the position and angle on the arc at a given fraction (of the total arc length)

length

Return the total length of the arc path

path_drawing_elements

Return the drawing elements of the single-headed arc path

points

Return the points of the arc path

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_children

Return the self children of the arc

self_drawing_elements

Return the self drawing elements of the single-headed arc

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

start_point

Return the starting point of the arc

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

arrowhead_base

arrowhead_base() -> Point

Return the arrowhead base anchor point of the single-headed arc

Source code in src/momapy/core.py
1089
1090
1091
1092
1093
1094
1095
1096
1097
def arrowhead_base(self) -> momapy.geometry.Point:
    """Return the arrowhead base anchor point of the single-headed arc"""
    arrowhead_length = self.arrowhead_length()
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return self.arrowhead_tip() - (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.end_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

arrowhead_bbox

arrowhead_bbox() -> Bbox

Return the bounding box of the single-headed arc arrowhead

Source code in src/momapy/core.py
1099
1100
1101
1102
1103
def arrowhead_bbox(self) -> momapy.geometry.Bbox:
    """Return the bounding box of the single-headed arc arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.arrowhead_drawing_elements()
    )

arrowhead_border

arrowhead_border(point) -> Point

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
def arrowhead_border(self, point) -> momapy.geometry.Point:
    """Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """

    point = momapy.drawing.get_drawing_elements_border(
        self.arrowhead_drawing_elements(), point
    )
    if point is None:
        return self.arrowhead_tip()
    return point

arrowhead_drawing_elements

arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the single-headed arc arrowhead

Source code in src/momapy/core.py
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
def arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the single-headed arc arrowhead"""
    elements = self._arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_arrowhead",
        elements=elements,
        fill=self.arrowhead_fill,
        filter=self.arrowhead_filter,
        id_=f"{self.id_}_arrowhead",
        stroke=self.arrowhead_stroke,
        stroke_dasharray=self.arrowhead_stroke_dasharray,
        stroke_dashoffset=self.arrowhead_stroke_dashoffset,
        stroke_width=self.arrowhead_stroke_width,
        transform=self.arrowhead_transform,
    )
    transformation = self._get_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

arrowhead_length

arrowhead_length() -> float

Return the length of the single-headed arc arrowhead

Source code in src/momapy/core.py
1071
1072
1073
1074
1075
1076
1077
1078
def arrowhead_length(self) -> float:
    """Return the length of the single-headed arc arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return bbox.east().x

arrowhead_tip

arrowhead_tip() -> Point

Return the arrowhead tip anchor point of the single-headed arc

Source code in src/momapy/core.py
1080
1081
1082
1083
1084
1085
1086
1087
def arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the arrowhead tip anchor point of the single-headed arc"""
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.end_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

childless

childless() -> Self

Return a copy of the arc with no children

Source code in src/momapy/core.py
978
979
980
def childless(self) -> typing.Self:
    """Return a copy of the arc with no children"""
    return dataclasses.replace(self, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

end_point

end_point() -> Point

Return the ending point of the arc

Source code in src/momapy/core.py
974
975
976
def end_point(self) -> momapy.geometry.Point:
    """Return the ending point of the arc"""
    return self.points()[-1]

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

fraction

fraction(fraction: float) -> tuple[Point, float]

Return the position and angle on the arc at a given fraction (of the total arc length)

Source code in src/momapy/core.py
982
983
984
985
986
987
988
989
990
991
def fraction(self, fraction: float) -> tuple[momapy.geometry.Point, float]:
    """Return the position and angle on the arc at a given fraction (of the total arc length)"""
    current_length = 0
    length_to_reach = fraction * self.length()
    for segment in self.segments:
        current_length += segment.length()
        if current_length >= length_to_reach:
            break
    position, angle = segment.get_position_and_angle_at_fraction(fraction)
    return position, angle

length

length()

Return the total length of the arc path

Source code in src/momapy/core.py
966
967
968
def length(self):
    """Return the total length of the arc path"""
    return sum([segment.length() for segment in self.segments])

path_drawing_elements

path_drawing_elements() -> list[Path]

Return the drawing elements of the single-headed arc path

Source code in src/momapy/core.py
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
def path_drawing_elements(self) -> list[momapy.drawing.Path]:
    """Return the drawing elements of the single-headed arc path"""
    arrowhead_length = self.arrowhead_length()
    if len(self.segments) == 1:
        segment = (
            self.segments[0]
            .shortened(self.start_shorten, "start")
            .shortened(self.end_shorten + arrowhead_length, "end")
        )
        actions = [
            momapy.drawing.MoveTo(segment.p1),
            self._make_path_action_from_segment(segment),
        ]
    else:
        first_segment = self.segments[0].shortened(
            self.start_shorten, "start"
        )
        last_segment = self.segments[-1].shortened(
            self.end_shorten + arrowhead_length, "end"
        )
        actions = [
            momapy.drawing.MoveTo(first_segment.p1),
            self._make_path_action_from_segment(first_segment),
        ]
        for segment in self.segments[1:-1]:
            action = self._make_path_action_from_segment(segment)
            actions.append(action)
        actions.append(self._make_path_action_from_segment(last_segment))
    path = momapy.drawing.Path(
        actions=actions,
        class_=f"{type(self).__name__}_path",
        fill=self.path_fill,
        filter=self.path_filter,
        id_=f"{self.id_}_path",
        stroke=self.path_stroke,
        stroke_dasharray=self.path_stroke_dasharray,
        stroke_dashoffset=self.path_stroke_dashoffset,
        stroke_width=self.path_stroke_width,
        transform=self.path_transform,
    )
    return [path]

points

points() -> list[Point]

Return the points of the arc path

Source code in src/momapy/core.py
958
959
960
961
962
963
964
def points(self) -> list[momapy.geometry.Point]:
    """Return the points of the arc path"""
    points = []
    for segment in self.segments:
        points.append(segment.p1)
    points.append(segment.p2)
    return points

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_children

self_children() -> list[LayoutElement]

Return the self children of the arc

Source code in src/momapy/core.py
954
955
956
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the arc"""
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the single-headed arc

Source code in src/momapy/core.py
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the single-headed arc"""
    elements = (
        self.path_drawing_elements() + self.arrowhead_drawing_elements()
    )
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

start_point

start_point() -> Point

Return the starting point of the arc

Source code in src/momapy/core.py
970
971
972
def start_point(self) -> momapy.geometry.Point:
    """Return the starting point of the arc"""
    return self.points()[0]

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

EquivalenceOperator dataclass

EquivalenceOperator(
    *,
    id_: str = get_uuid4_as_str(),
    inputs: frozenset[
        EquivalenceOperatorInput
    ] = frozenset(),
    output: EquivalenceOperatorOutput | None = None
)

Bases: SBGNModelElement

Class for equivalence operators

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'2abb0f21-fb66-490a-b925-8fa859c30cb7'
output EquivalenceOperatorOutput | None
None

EquivalenceOperatorInput dataclass

EquivalenceOperatorInput(
    *, id_: str = get_uuid4_as_str(), element: EntityPool
)

Bases: SBGNRole

Class for inputs of equivalence operators

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'5e3acb64-a6db-4bb4-82fd-a1fb3702c493'
element EntityPool
required

EquivalenceOperatorLayout dataclass

EquivalenceOperatorLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 30.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 30.0,
    direction: Direction = HORIZONTAL,
    left_to_right: bool = True,
    left_connector_length: float = 10.0,
    right_connector_length: float = 10.0,
    left_connector_stroke: (
        NoneValueType | Color | None
    ) = None,
    left_connector_stroke_width: float | None = None,
    left_connector_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    left_connector_stroke_dashoffset: float | None = None,
    left_connector_fill: (
        NoneValueType | Color | None
    ) = None,
    left_connector_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    left_connector_filter: (
        NoneValueType | Filter | None
    ) = None,
    right_connector_stroke: (
        NoneValueType | Color | None
    ) = None,
    right_connector_stroke_width: float | None = None,
    right_connector_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    right_connector_stroke_dashoffset: float | None = None,
    right_connector_fill: (
        NoneValueType | Color | None
    ) = None,
    right_connector_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    right_connector_filter: (
        NoneValueType | Filter | None
    ) = None
)

Bases: _ConnectorsMixin, _SimpleMixin, _TextMixin, SBGNNode

Class for equivalence operator layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'504616bb-9e9e-41ba-b4be-29db28feb025'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
30.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
30.0
direction Direction
<Direction.HORIZONTAL: 1>
left_to_right bool
True
left_connector_length float
10.0
right_connector_length float
10.0
left_connector_stroke NoneValueType | Color | None
None
left_connector_stroke_width float | None
None
left_connector_stroke_dasharray NoneValueType | tuple[float] | None
None
left_connector_stroke_dashoffset float | None
None
left_connector_fill NoneValueType | Color | None
None
left_connector_transform NoneValueType | tuple[Transformation] | None
None
left_connector_filter NoneValueType | Filter | None
None
right_connector_stroke NoneValueType | Color | None
None
right_connector_stroke_width float | None
None
right_connector_stroke_dasharray NoneValueType | tuple[float] | None
None
right_connector_stroke_dashoffset float | None
None
right_connector_fill NoneValueType | Color | None
None
right_connector_transform NoneValueType | tuple[Transformation] | None
None
right_connector_filter NoneValueType | Filter | None
None

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
791
792
793
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

EquivalenceOperatorOutput dataclass

EquivalenceOperatorOutput(
    *, id_: str = get_uuid4_as_str(), element: EntityPool
)

Bases: SBGNRole

Class for outputs of equivalence operators

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'2563d2ae-ce40-4bef-bd5a-0b32fcfb5d96'
element EntityPool
required

FluxRole dataclass

FluxRole(
    *,
    id_: str = get_uuid4_as_str(),
    element: EntityPool,
    stoichiometry: int | None = None
)

Bases: SBGNRole

Base class for flux roles

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'0513cf04-2f7d-44bb-8d31-e8571763a8cb'
element EntityPool
required
stoichiometry int | None
None

GenericProcess dataclass

GenericProcess(
    *,
    id_: str = get_uuid4_as_str(),
    reactants: frozenset[Reactant] = frozenset(),
    products: frozenset[Product] = frozenset(),
    reversible: bool = False
)

Bases: StoichiometricProcess

Class for generic processes

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'cba11dae-8ce5-4ab3-acbb-d0ed19f35a06'
reversible bool
False

GenericProcessLayout dataclass

GenericProcessLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 20.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 20.0,
    direction: Direction = HORIZONTAL,
    left_to_right: bool = True,
    left_connector_length: float = 10.0,
    right_connector_length: float = 10.0,
    left_connector_stroke: (
        NoneValueType | Color | None
    ) = None,
    left_connector_stroke_width: float | None = None,
    left_connector_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    left_connector_stroke_dashoffset: float | None = None,
    left_connector_fill: (
        NoneValueType | Color | None
    ) = None,
    left_connector_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    left_connector_filter: (
        NoneValueType | Filter | None
    ) = None,
    right_connector_stroke: (
        NoneValueType | Color | None
    ) = None,
    right_connector_stroke_width: float | None = None,
    right_connector_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    right_connector_stroke_dashoffset: float | None = None,
    right_connector_fill: (
        NoneValueType | Color | None
    ) = None,
    right_connector_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    right_connector_filter: (
        NoneValueType | Filter | None
    ) = None
)

Bases: _ConnectorsMixin, _SimpleMixin, SBGNNode

Class for generic process layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'397ca594-b856-48e1-ab96-372d19b1e53c'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
20.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
20.0
direction Direction
<Direction.HORIZONTAL: 1>
left_to_right bool
True
left_connector_length float
10.0
right_connector_length float
10.0
left_connector_stroke NoneValueType | Color | None
None
left_connector_stroke_width float | None
None
left_connector_stroke_dasharray NoneValueType | tuple[float] | None
None
left_connector_stroke_dashoffset float | None
None
left_connector_fill NoneValueType | Color | None
None
left_connector_transform NoneValueType | tuple[Transformation] | None
None
left_connector_filter NoneValueType | Filter | None
None
right_connector_stroke NoneValueType | Color | None
None
right_connector_stroke_width float | None
None
right_connector_stroke_dasharray NoneValueType | tuple[float] | None
None
right_connector_stroke_dashoffset float | None
None
right_connector_fill NoneValueType | Color | None
None
right_connector_transform NoneValueType | tuple[Transformation] | None
None
right_connector_filter NoneValueType | Filter | None
None

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
791
792
793
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

Inhibition dataclass

Inhibition(
    *,
    id_: str = get_uuid4_as_str(),
    source: EntityPool | LogicalOperator,
    target: Process
)

Bases: Modulation

Class for inhibitions

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'e2eb747d-4c04-4867-a920-fbdc21d64027'
source EntityPool | LogicalOperator
required
target Process
required

InhibitionLayout dataclass

InhibitionLayout(
    path_fill: NoneValueType | Color | None = NoneValue,
    path_stroke: NoneValueType | Color | None = black,
    path_stroke_width: float | None = 1.25,
    arrowhead_fill: NoneValueType | Color | None = white,
    arrowhead_stroke: NoneValueType | Color | None = black,
    arrowhead_stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_shorten: float = 0.0,
    fill: NoneValueType | Color | None = None,
    filter: NoneValueType | Filter | None = None,
    path_filter: NoneValueType | Filter | None = None,
    path_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    path_stroke_dashoffset: float | None = None,
    path_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    stroke: NoneValueType | Color | None = None,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    stroke_width: float | None = None,
    segments: tuple[
        Segment | BezierCurve | EllipticalArc
    ] = tuple(),
    source: LayoutElement | None = None,
    start_shorten: float = 0.0,
    target: LayoutElement | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    arrowhead_filter: NoneValueType | Filter | None = None,
    arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    arrowhead_stroke_dashoffset: float | None = None,
    arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    arrowhead_height: float = 10.0
)

Bases: SBGNSingleHeadedArc

Class for inhibition layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'1532d04f-8f6a-4c62-87cb-d3e2c90a76eb'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
end_shorten float

The length the end of the arc will be shorten by

0.0
fill NoneValueType | Color | None

The fill color of the arc

None
filter NoneValueType | Filter | None

The fill filter of the arc

None
path_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
path_filter NoneValueType | Filter | None

The path filter of the arc

None
path_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
path_stroke_dasharray NoneValueType | tuple[float] | None

The path stroke dasharray of the arc

None
path_stroke_dashoffset float | None

The path stroke dashoffset of the arc

None
path_stroke_width float | None
1.25
path_transform NoneValueType | tuple[Transformation] | None

The path transform of the arc

None
stroke NoneValueType | Color | None

The stroke color of the arc

None
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the arc

None
stroke_dashoffset float | None

The stroke dashoffset of the arc

None
stroke_width float | None

The stroke width of the arc

None
segments tuple[Union[Segment, BezierCurve, EllipticalArc]]

The path segments of the arc

<dynamic>
source LayoutElement | None

The source of the arc

None
start_shorten float

The length the start of the arc will be shorten by

0.0
target LayoutElement | None

The target of the arc

None
transform NoneValueType | tuple[Transformation] | None

The transform of the arc

None
arrowhead_fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
arrowhead_filter NoneValueType | Filter | None

The arrowhead filter of the arc

None
arrowhead_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
arrowhead_stroke_dasharray NoneValueType | tuple[float] | None

The arrowhead stroke dasharray of the arc

None
arrowhead_stroke_dashoffset float | None

The arrowhead stroke dashoffset of the arc

None
arrowhead_stroke_width float | None
1.25
arrowhead_transform NoneValueType | tuple[Transformation] | None

The arrowhead transform of the arc

None
arrowhead_height float
10.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

arrowhead_base

Return the arrowhead base anchor point of the single-headed arc

arrowhead_bbox

Return the bounding box of the single-headed arc arrowhead

arrowhead_border

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.

arrowhead_drawing_elements

Return the drawing elements of the single-headed arc arrowhead

arrowhead_length

Return the length of the single-headed arc arrowhead

arrowhead_tip

Return the arrowhead tip anchor point of the single-headed arc

bbox

Compute and return the bounding box of the layout element

childless

Return a copy of the arc with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

end_point

Return the ending point of the arc

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

fraction

Return the position and angle on the arc at a given fraction (of the total arc length)

length

Return the total length of the arc path

path_drawing_elements

Return the drawing elements of the single-headed arc path

points

Return the points of the arc path

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_children

Return the self children of the arc

self_drawing_elements

Return the self drawing elements of the single-headed arc

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

start_point

Return the starting point of the arc

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

arrowhead_base

arrowhead_base() -> Point

Return the arrowhead base anchor point of the single-headed arc

Source code in src/momapy/core.py
1089
1090
1091
1092
1093
1094
1095
1096
1097
def arrowhead_base(self) -> momapy.geometry.Point:
    """Return the arrowhead base anchor point of the single-headed arc"""
    arrowhead_length = self.arrowhead_length()
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return self.arrowhead_tip() - (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.end_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

arrowhead_bbox

arrowhead_bbox() -> Bbox

Return the bounding box of the single-headed arc arrowhead

Source code in src/momapy/core.py
1099
1100
1101
1102
1103
def arrowhead_bbox(self) -> momapy.geometry.Bbox:
    """Return the bounding box of the single-headed arc arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.arrowhead_drawing_elements()
    )

arrowhead_border

arrowhead_border(point) -> Point

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
def arrowhead_border(self, point) -> momapy.geometry.Point:
    """Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """

    point = momapy.drawing.get_drawing_elements_border(
        self.arrowhead_drawing_elements(), point
    )
    if point is None:
        return self.arrowhead_tip()
    return point

arrowhead_drawing_elements

arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the single-headed arc arrowhead

Source code in src/momapy/core.py
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
def arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the single-headed arc arrowhead"""
    elements = self._arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_arrowhead",
        elements=elements,
        fill=self.arrowhead_fill,
        filter=self.arrowhead_filter,
        id_=f"{self.id_}_arrowhead",
        stroke=self.arrowhead_stroke,
        stroke_dasharray=self.arrowhead_stroke_dasharray,
        stroke_dashoffset=self.arrowhead_stroke_dashoffset,
        stroke_width=self.arrowhead_stroke_width,
        transform=self.arrowhead_transform,
    )
    transformation = self._get_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

arrowhead_length

arrowhead_length() -> float

Return the length of the single-headed arc arrowhead

Source code in src/momapy/core.py
1071
1072
1073
1074
1075
1076
1077
1078
def arrowhead_length(self) -> float:
    """Return the length of the single-headed arc arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return bbox.east().x

arrowhead_tip

arrowhead_tip() -> Point

Return the arrowhead tip anchor point of the single-headed arc

Source code in src/momapy/core.py
1080
1081
1082
1083
1084
1085
1086
1087
def arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the arrowhead tip anchor point of the single-headed arc"""
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.end_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

childless

childless() -> Self

Return a copy of the arc with no children

Source code in src/momapy/core.py
978
979
980
def childless(self) -> typing.Self:
    """Return a copy of the arc with no children"""
    return dataclasses.replace(self, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

end_point

end_point() -> Point

Return the ending point of the arc

Source code in src/momapy/core.py
974
975
976
def end_point(self) -> momapy.geometry.Point:
    """Return the ending point of the arc"""
    return self.points()[-1]

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

fraction

fraction(fraction: float) -> tuple[Point, float]

Return the position and angle on the arc at a given fraction (of the total arc length)

Source code in src/momapy/core.py
982
983
984
985
986
987
988
989
990
991
def fraction(self, fraction: float) -> tuple[momapy.geometry.Point, float]:
    """Return the position and angle on the arc at a given fraction (of the total arc length)"""
    current_length = 0
    length_to_reach = fraction * self.length()
    for segment in self.segments:
        current_length += segment.length()
        if current_length >= length_to_reach:
            break
    position, angle = segment.get_position_and_angle_at_fraction(fraction)
    return position, angle

length

length()

Return the total length of the arc path

Source code in src/momapy/core.py
966
967
968
def length(self):
    """Return the total length of the arc path"""
    return sum([segment.length() for segment in self.segments])

path_drawing_elements

path_drawing_elements() -> list[Path]

Return the drawing elements of the single-headed arc path

Source code in src/momapy/core.py
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
def path_drawing_elements(self) -> list[momapy.drawing.Path]:
    """Return the drawing elements of the single-headed arc path"""
    arrowhead_length = self.arrowhead_length()
    if len(self.segments) == 1:
        segment = (
            self.segments[0]
            .shortened(self.start_shorten, "start")
            .shortened(self.end_shorten + arrowhead_length, "end")
        )
        actions = [
            momapy.drawing.MoveTo(segment.p1),
            self._make_path_action_from_segment(segment),
        ]
    else:
        first_segment = self.segments[0].shortened(
            self.start_shorten, "start"
        )
        last_segment = self.segments[-1].shortened(
            self.end_shorten + arrowhead_length, "end"
        )
        actions = [
            momapy.drawing.MoveTo(first_segment.p1),
            self._make_path_action_from_segment(first_segment),
        ]
        for segment in self.segments[1:-1]:
            action = self._make_path_action_from_segment(segment)
            actions.append(action)
        actions.append(self._make_path_action_from_segment(last_segment))
    path = momapy.drawing.Path(
        actions=actions,
        class_=f"{type(self).__name__}_path",
        fill=self.path_fill,
        filter=self.path_filter,
        id_=f"{self.id_}_path",
        stroke=self.path_stroke,
        stroke_dasharray=self.path_stroke_dasharray,
        stroke_dashoffset=self.path_stroke_dashoffset,
        stroke_width=self.path_stroke_width,
        transform=self.path_transform,
    )
    return [path]

points

points() -> list[Point]

Return the points of the arc path

Source code in src/momapy/core.py
958
959
960
961
962
963
964
def points(self) -> list[momapy.geometry.Point]:
    """Return the points of the arc path"""
    points = []
    for segment in self.segments:
        points.append(segment.p1)
    points.append(segment.p2)
    return points

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_children

self_children() -> list[LayoutElement]

Return the self children of the arc

Source code in src/momapy/core.py
954
955
956
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the arc"""
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the single-headed arc

Source code in src/momapy/core.py
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the single-headed arc"""
    elements = (
        self.path_drawing_elements() + self.arrowhead_drawing_elements()
    )
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

start_point

start_point() -> Point

Return the starting point of the arc

Source code in src/momapy/core.py
970
971
972
def start_point(self) -> momapy.geometry.Point:
    """Return the starting point of the arc"""
    return self.points()[0]

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

LogicArcLayout dataclass

LogicArcLayout(
    path_fill: NoneValueType | Color | None = NoneValue,
    path_stroke: NoneValueType | Color | None = black,
    path_stroke_width: float | None = 1.25,
    arrowhead_fill: NoneValueType | Color | None = white,
    arrowhead_stroke: NoneValueType | Color | None = black,
    arrowhead_stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_shorten: float = 0.0,
    fill: NoneValueType | Color | None = None,
    filter: NoneValueType | Filter | None = None,
    path_filter: NoneValueType | Filter | None = None,
    path_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    path_stroke_dashoffset: float | None = None,
    path_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    stroke: NoneValueType | Color | None = None,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    stroke_width: float | None = None,
    segments: tuple[
        Segment | BezierCurve | EllipticalArc
    ] = tuple(),
    source: LayoutElement | None = None,
    start_shorten: float = 0.0,
    target: LayoutElement | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    arrowhead_filter: NoneValueType | Filter | None = None,
    arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    arrowhead_stroke_dashoffset: float | None = None,
    arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None
)

Bases: SBGNSingleHeadedArc

Class for logic arc layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'e2a3ea9e-5bb2-4e42-a1ec-5579500346c8'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
end_shorten float

The length the end of the arc will be shorten by

0.0
fill NoneValueType | Color | None

The fill color of the arc

None
filter NoneValueType | Filter | None

The fill filter of the arc

None
path_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
path_filter NoneValueType | Filter | None

The path filter of the arc

None
path_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
path_stroke_dasharray NoneValueType | tuple[float] | None

The path stroke dasharray of the arc

None
path_stroke_dashoffset float | None

The path stroke dashoffset of the arc

None
path_stroke_width float | None
1.25
path_transform NoneValueType | tuple[Transformation] | None

The path transform of the arc

None
stroke NoneValueType | Color | None

The stroke color of the arc

None
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the arc

None
stroke_dashoffset float | None

The stroke dashoffset of the arc

None
stroke_width float | None

The stroke width of the arc

None
segments tuple[Union[Segment, BezierCurve, EllipticalArc]]

The path segments of the arc

<dynamic>
source LayoutElement | None

The source of the arc

None
start_shorten float

The length the start of the arc will be shorten by

0.0
target LayoutElement | None

The target of the arc

None
transform NoneValueType | tuple[Transformation] | None

The transform of the arc

None
arrowhead_fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
arrowhead_filter NoneValueType | Filter | None

The arrowhead filter of the arc

None
arrowhead_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
arrowhead_stroke_dasharray NoneValueType | tuple[float] | None

The arrowhead stroke dasharray of the arc

None
arrowhead_stroke_dashoffset float | None

The arrowhead stroke dashoffset of the arc

None
arrowhead_stroke_width float | None
1.25
arrowhead_transform NoneValueType | tuple[Transformation] | None

The arrowhead transform of the arc

None

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

arrowhead_base

Return the arrowhead base anchor point of the single-headed arc

arrowhead_bbox

Return the bounding box of the single-headed arc arrowhead

arrowhead_border

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.

arrowhead_drawing_elements

Return the drawing elements of the single-headed arc arrowhead

arrowhead_length

Return the length of the single-headed arc arrowhead

arrowhead_tip

Return the arrowhead tip anchor point of the single-headed arc

bbox

Compute and return the bounding box of the layout element

childless

Return a copy of the arc with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

end_point

Return the ending point of the arc

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

fraction

Return the position and angle on the arc at a given fraction (of the total arc length)

length

Return the total length of the arc path

path_drawing_elements

Return the drawing elements of the single-headed arc path

points

Return the points of the arc path

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_children

Return the self children of the arc

self_drawing_elements

Return the self drawing elements of the single-headed arc

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

start_point

Return the starting point of the arc

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

arrowhead_base

arrowhead_base() -> Point

Return the arrowhead base anchor point of the single-headed arc

Source code in src/momapy/core.py
1089
1090
1091
1092
1093
1094
1095
1096
1097
def arrowhead_base(self) -> momapy.geometry.Point:
    """Return the arrowhead base anchor point of the single-headed arc"""
    arrowhead_length = self.arrowhead_length()
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return self.arrowhead_tip() - (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.end_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

arrowhead_bbox

arrowhead_bbox() -> Bbox

Return the bounding box of the single-headed arc arrowhead

Source code in src/momapy/core.py
1099
1100
1101
1102
1103
def arrowhead_bbox(self) -> momapy.geometry.Bbox:
    """Return the bounding box of the single-headed arc arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.arrowhead_drawing_elements()
    )

arrowhead_border

arrowhead_border(point) -> Point

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
def arrowhead_border(self, point) -> momapy.geometry.Point:
    """Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """

    point = momapy.drawing.get_drawing_elements_border(
        self.arrowhead_drawing_elements(), point
    )
    if point is None:
        return self.arrowhead_tip()
    return point

arrowhead_drawing_elements

arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the single-headed arc arrowhead

Source code in src/momapy/core.py
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
def arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the single-headed arc arrowhead"""
    elements = self._arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_arrowhead",
        elements=elements,
        fill=self.arrowhead_fill,
        filter=self.arrowhead_filter,
        id_=f"{self.id_}_arrowhead",
        stroke=self.arrowhead_stroke,
        stroke_dasharray=self.arrowhead_stroke_dasharray,
        stroke_dashoffset=self.arrowhead_stroke_dashoffset,
        stroke_width=self.arrowhead_stroke_width,
        transform=self.arrowhead_transform,
    )
    transformation = self._get_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

arrowhead_length

arrowhead_length() -> float

Return the length of the single-headed arc arrowhead

Source code in src/momapy/core.py
1071
1072
1073
1074
1075
1076
1077
1078
def arrowhead_length(self) -> float:
    """Return the length of the single-headed arc arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return bbox.east().x

arrowhead_tip

arrowhead_tip() -> Point

Return the arrowhead tip anchor point of the single-headed arc

Source code in src/momapy/core.py
1080
1081
1082
1083
1084
1085
1086
1087
def arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the arrowhead tip anchor point of the single-headed arc"""
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.end_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

childless

childless() -> Self

Return a copy of the arc with no children

Source code in src/momapy/core.py
978
979
980
def childless(self) -> typing.Self:
    """Return a copy of the arc with no children"""
    return dataclasses.replace(self, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

end_point

end_point() -> Point

Return the ending point of the arc

Source code in src/momapy/core.py
974
975
976
def end_point(self) -> momapy.geometry.Point:
    """Return the ending point of the arc"""
    return self.points()[-1]

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

fraction

fraction(fraction: float) -> tuple[Point, float]

Return the position and angle on the arc at a given fraction (of the total arc length)

Source code in src/momapy/core.py
982
983
984
985
986
987
988
989
990
991
def fraction(self, fraction: float) -> tuple[momapy.geometry.Point, float]:
    """Return the position and angle on the arc at a given fraction (of the total arc length)"""
    current_length = 0
    length_to_reach = fraction * self.length()
    for segment in self.segments:
        current_length += segment.length()
        if current_length >= length_to_reach:
            break
    position, angle = segment.get_position_and_angle_at_fraction(fraction)
    return position, angle

length

length()

Return the total length of the arc path

Source code in src/momapy/core.py
966
967
968
def length(self):
    """Return the total length of the arc path"""
    return sum([segment.length() for segment in self.segments])

path_drawing_elements

path_drawing_elements() -> list[Path]

Return the drawing elements of the single-headed arc path

Source code in src/momapy/core.py
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
def path_drawing_elements(self) -> list[momapy.drawing.Path]:
    """Return the drawing elements of the single-headed arc path"""
    arrowhead_length = self.arrowhead_length()
    if len(self.segments) == 1:
        segment = (
            self.segments[0]
            .shortened(self.start_shorten, "start")
            .shortened(self.end_shorten + arrowhead_length, "end")
        )
        actions = [
            momapy.drawing.MoveTo(segment.p1),
            self._make_path_action_from_segment(segment),
        ]
    else:
        first_segment = self.segments[0].shortened(
            self.start_shorten, "start"
        )
        last_segment = self.segments[-1].shortened(
            self.end_shorten + arrowhead_length, "end"
        )
        actions = [
            momapy.drawing.MoveTo(first_segment.p1),
            self._make_path_action_from_segment(first_segment),
        ]
        for segment in self.segments[1:-1]:
            action = self._make_path_action_from_segment(segment)
            actions.append(action)
        actions.append(self._make_path_action_from_segment(last_segment))
    path = momapy.drawing.Path(
        actions=actions,
        class_=f"{type(self).__name__}_path",
        fill=self.path_fill,
        filter=self.path_filter,
        id_=f"{self.id_}_path",
        stroke=self.path_stroke,
        stroke_dasharray=self.path_stroke_dasharray,
        stroke_dashoffset=self.path_stroke_dashoffset,
        stroke_width=self.path_stroke_width,
        transform=self.path_transform,
    )
    return [path]

points

points() -> list[Point]

Return the points of the arc path

Source code in src/momapy/core.py
958
959
960
961
962
963
964
def points(self) -> list[momapy.geometry.Point]:
    """Return the points of the arc path"""
    points = []
    for segment in self.segments:
        points.append(segment.p1)
    points.append(segment.p2)
    return points

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_children

self_children() -> list[LayoutElement]

Return the self children of the arc

Source code in src/momapy/core.py
954
955
956
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the arc"""
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the single-headed arc

Source code in src/momapy/core.py
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the single-headed arc"""
    elements = (
        self.path_drawing_elements() + self.arrowhead_drawing_elements()
    )
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

start_point

start_point() -> Point

Return the starting point of the arc

Source code in src/momapy/core.py
970
971
972
def start_point(self) -> momapy.geometry.Point:
    """Return the starting point of the arc"""
    return self.points()[0]

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

LogicalOperator dataclass

LogicalOperator(
    *,
    id_: str = get_uuid4_as_str(),
    inputs: frozenset[LogicalOperatorInput] = frozenset()
)

Bases: SBGNModelElement

Class for logical operators

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'f6ba3aa7-571e-4e59-bbc7-cf9ee1b6d2d9'

LogicalOperatorInput dataclass

LogicalOperatorInput(
    *,
    id_: str = get_uuid4_as_str(),
    element: Union[
        EntityPool,
        ForwardRef(
            LogicalOperator, module=modules[__name__]
        ),
    ]
)

Bases: SBGNRole

Class for inputs of logical operators

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'082b147e-8ec6-4334-ae9b-901b010bf5ea'
element EntityPool | ForwardRef('LogicalOperator', module=<module 'momapy.sbgn.pd' from '/home/rougny/code/momapy/src/momapy/sbgn/pd.py'>)
required

Macromolecule dataclass

Macromolecule(
    *,
    id_: str = get_uuid4_as_str(),
    compartment: Compartment | None = None,
    label: str | None = None,
    state_variables: frozenset[StateVariable] = frozenset(),
    units_of_information: frozenset[
        UnitOfInformation
    ] = frozenset()
)

Bases: EntityPool

Class for macromolecules

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'0b38b799-698e-4fb6-8619-5351d845ff72'
compartment Compartment | None
None
label str | None
None

MacromoleculeLayout dataclass

MacromoleculeLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 30.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 60.0,
    rounded_corners: float = 5.0
)

Bases: _SimpleMixin, SBGNNode

Class for macromolecule layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'6e8a04cc-a56e-4dab-a2cf-372ee5606533'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
30.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
60.0
rounded_corners float
5.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
791
792
793
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

MacromoleculeMultimer dataclass

MacromoleculeMultimer(
    *,
    id_: str = get_uuid4_as_str(),
    compartment: Compartment | None = None,
    label: str | None = None,
    state_variables: frozenset[StateVariable] = frozenset(),
    units_of_information: frozenset[
        UnitOfInformation
    ] = frozenset(),
    subunits: frozenset[Subunit] = frozenset(),
    cardinality: int | None = None
)

Bases: Multimer

Class for macromolecule multimers

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'ca2aa06a-7f75-4ff0-b179-bad4a446e466'
compartment Compartment | None
None
label str | None
None
cardinality int | None
None

MacromoleculeMultimerLayout dataclass

MacromoleculeMultimerLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    offset: float = 3.0,
    subunits_stroke: (
        tuple[NoneValueType | Color] | None
    ) = None,
    subunits_stroke_width: (
        tuple[NoneValueType | float] | None
    ) = None,
    subunits_stroke_dasharray: (
        tuple[NoneValueType | tuple[float]] | None
    ) = None,
    subunits_stroke_dashoffset: tuple[float] | None = None,
    subunits_fill: (
        tuple[NoneValueType | Color] | None
    ) = None,
    subunits_transform: (
        tuple[NoneValueType | tuple[Transformation]] | None
    ) = None,
    subunits_filter: (
        tuple[NoneValueType | Filter] | None
    ) = None,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 30.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 60.0,
    rounded_corners: float = 5.0
)

Bases: _MultiMixin, SBGNNode

Class for macromolecule multimer layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'd8ec0c42-f1a6-48af-9a3f-d2a8e5cf8a93'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
30.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
60.0
offset float
3.0
subunits_stroke tuple[Union[NoneValueType, Color]] | None
None
subunits_stroke_width tuple[Union[NoneValueType, float]] | None
None
subunits_stroke_dasharray tuple[Union[NoneValueType, tuple[float]]] | None
None
subunits_stroke_dashoffset tuple[float] | None
None
subunits_fill tuple[Union[NoneValueType, Color]] | None
None
subunits_transform tuple[Union[NoneValueType, tuple[Transformation]]] | None
None
subunits_filter tuple[Union[NoneValueType, Filter]] | None
None
rounded_corners float
5.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

MacromoleculeMultimerSubunit dataclass

MacromoleculeMultimerSubunit(
    *,
    id_: str = get_uuid4_as_str(),
    label: str | None = None,
    state_variables: frozenset[StateVariable] = frozenset(),
    units_of_information: frozenset[
        UnitOfInformation
    ] = frozenset(),
    subunits: frozenset[Subunit] = frozenset(),
    cardinality: int | None = None
)

Bases: MultimerSubunit

Class for macromolecule multimer subunits

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'92b4fa77-e112-4cd3-9b14-fc36a4719003'
label str | None
None
cardinality int | None
None

MacromoleculeMultimerSubunitLayout dataclass

MacromoleculeMultimerSubunitLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    offset: float = 3.0,
    subunits_stroke: (
        tuple[NoneValueType | Color] | None
    ) = None,
    subunits_stroke_width: (
        tuple[NoneValueType | float] | None
    ) = None,
    subunits_stroke_dasharray: (
        tuple[NoneValueType | tuple[float]] | None
    ) = None,
    subunits_stroke_dashoffset: tuple[float] | None = None,
    subunits_fill: (
        tuple[NoneValueType | Color] | None
    ) = None,
    subunits_transform: (
        tuple[NoneValueType | tuple[Transformation]] | None
    ) = None,
    subunits_filter: (
        tuple[NoneValueType | Filter] | None
    ) = None,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 30.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 60.0,
    rounded_corners: float = 5.0
)

Bases: _MultiMixin, SBGNNode

Class for macromolecule multimer subunit layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'5ffda5f0-6e3d-49b3-927c-a2aae8ec8140'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
30.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
60.0
offset float
3.0
subunits_stroke tuple[Union[NoneValueType, Color]] | None
None
subunits_stroke_width tuple[Union[NoneValueType, float]] | None
None
subunits_stroke_dasharray tuple[Union[NoneValueType, tuple[float]]] | None
None
subunits_stroke_dashoffset tuple[float] | None
None
subunits_fill tuple[Union[NoneValueType, Color]] | None
None
subunits_transform tuple[Union[NoneValueType, tuple[Transformation]]] | None
None
subunits_filter tuple[Union[NoneValueType, Filter]] | None
None
rounded_corners float
5.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

MacromoleculeSubunit dataclass

MacromoleculeSubunit(
    *,
    id_: str = get_uuid4_as_str(),
    label: str | None = None,
    state_variables: frozenset[StateVariable] = frozenset(),
    units_of_information: frozenset[
        UnitOfInformation
    ] = frozenset()
)

Bases: Subunit

Class for macromolecule subunits

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'20a95d74-9a38-4d82-b2aa-bfd58ac04508'
label str | None
None

MacromoleculeSubunitLayout dataclass

MacromoleculeSubunitLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 30.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 60.0,
    rounded_corners: float = 5.0
)

Bases: _SimpleMixin, SBGNNode

Class for macromolecule subunit layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'0f3b2b3a-6c5e-475e-b1aa-7f46dbb7bd78'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
30.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
60.0
rounded_corners float
5.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
791
792
793
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

Modulation dataclass

Modulation(
    *,
    id_: str = get_uuid4_as_str(),
    source: EntityPool | LogicalOperator,
    target: Process
)

Bases: SBGNModelElement

Class for modulations

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'de0b96c9-5465-4610-9a90-6c468516ab3f'
source EntityPool | LogicalOperator
required
target Process
required

ModulationLayout dataclass

ModulationLayout(
    path_fill: NoneValueType | Color | None = NoneValue,
    path_stroke: NoneValueType | Color | None = black,
    path_stroke_width: float | None = 1.25,
    arrowhead_stroke: NoneValueType | Color | None = black,
    arrowhead_stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_shorten: float = 0.0,
    fill: NoneValueType | Color | None = None,
    filter: NoneValueType | Filter | None = None,
    path_filter: NoneValueType | Filter | None = None,
    path_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    path_stroke_dashoffset: float | None = None,
    path_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    stroke: NoneValueType | Color | None = None,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    stroke_width: float | None = None,
    segments: tuple[
        Segment | BezierCurve | EllipticalArc
    ] = tuple(),
    source: LayoutElement | None = None,
    start_shorten: float = 0.0,
    target: LayoutElement | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    arrowhead_fill: NoneValueType | Color | None = white,
    arrowhead_filter: NoneValueType | Filter | None = None,
    arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    arrowhead_stroke_dashoffset: float | None = None,
    arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    arrowhead_height: float = 10.0,
    arrowhead_width: float = 10.0
)

Bases: SBGNSingleHeadedArc

Class for modulation layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'75a6a148-d447-4142-85d6-073bbd9d0def'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
end_shorten float

The length the end of the arc will be shorten by

0.0
fill NoneValueType | Color | None

The fill color of the arc

None
filter NoneValueType | Filter | None

The fill filter of the arc

None
path_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
path_filter NoneValueType | Filter | None

The path filter of the arc

None
path_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
path_stroke_dasharray NoneValueType | tuple[float] | None

The path stroke dasharray of the arc

None
path_stroke_dashoffset float | None

The path stroke dashoffset of the arc

None
path_stroke_width float | None
1.25
path_transform NoneValueType | tuple[Transformation] | None

The path transform of the arc

None
stroke NoneValueType | Color | None

The stroke color of the arc

None
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the arc

None
stroke_dashoffset float | None

The stroke dashoffset of the arc

None
stroke_width float | None

The stroke width of the arc

None
segments tuple[Union[Segment, BezierCurve, EllipticalArc]]

The path segments of the arc

<dynamic>
source LayoutElement | None

The source of the arc

None
start_shorten float

The length the start of the arc will be shorten by

0.0
target LayoutElement | None

The target of the arc

None
transform NoneValueType | tuple[Transformation] | None

The transform of the arc

None
arrowhead_fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
arrowhead_filter NoneValueType | Filter | None

The arrowhead filter of the arc

None
arrowhead_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
arrowhead_stroke_dasharray NoneValueType | tuple[float] | None

The arrowhead stroke dasharray of the arc

None
arrowhead_stroke_dashoffset float | None

The arrowhead stroke dashoffset of the arc

None
arrowhead_stroke_width float | None
1.25
arrowhead_transform NoneValueType | tuple[Transformation] | None

The arrowhead transform of the arc

None
arrowhead_height float
10.0
arrowhead_width float
10.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

arrowhead_base

Return the arrowhead base anchor point of the single-headed arc

arrowhead_bbox

Return the bounding box of the single-headed arc arrowhead

arrowhead_border

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.

arrowhead_drawing_elements

Return the drawing elements of the single-headed arc arrowhead

arrowhead_length

Return the length of the single-headed arc arrowhead

arrowhead_tip

Return the arrowhead tip anchor point of the single-headed arc

bbox

Compute and return the bounding box of the layout element

childless

Return a copy of the arc with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

end_point

Return the ending point of the arc

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

fraction

Return the position and angle on the arc at a given fraction (of the total arc length)

length

Return the total length of the arc path

path_drawing_elements

Return the drawing elements of the single-headed arc path

points

Return the points of the arc path

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_children

Return the self children of the arc

self_drawing_elements

Return the self drawing elements of the single-headed arc

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

start_point

Return the starting point of the arc

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

arrowhead_base

arrowhead_base() -> Point

Return the arrowhead base anchor point of the single-headed arc

Source code in src/momapy/core.py
1089
1090
1091
1092
1093
1094
1095
1096
1097
def arrowhead_base(self) -> momapy.geometry.Point:
    """Return the arrowhead base anchor point of the single-headed arc"""
    arrowhead_length = self.arrowhead_length()
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return self.arrowhead_tip() - (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.end_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

arrowhead_bbox

arrowhead_bbox() -> Bbox

Return the bounding box of the single-headed arc arrowhead

Source code in src/momapy/core.py
1099
1100
1101
1102
1103
def arrowhead_bbox(self) -> momapy.geometry.Bbox:
    """Return the bounding box of the single-headed arc arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.arrowhead_drawing_elements()
    )

arrowhead_border

arrowhead_border(point) -> Point

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
def arrowhead_border(self, point) -> momapy.geometry.Point:
    """Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """

    point = momapy.drawing.get_drawing_elements_border(
        self.arrowhead_drawing_elements(), point
    )
    if point is None:
        return self.arrowhead_tip()
    return point

arrowhead_drawing_elements

arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the single-headed arc arrowhead

Source code in src/momapy/core.py
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
def arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the single-headed arc arrowhead"""
    elements = self._arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_arrowhead",
        elements=elements,
        fill=self.arrowhead_fill,
        filter=self.arrowhead_filter,
        id_=f"{self.id_}_arrowhead",
        stroke=self.arrowhead_stroke,
        stroke_dasharray=self.arrowhead_stroke_dasharray,
        stroke_dashoffset=self.arrowhead_stroke_dashoffset,
        stroke_width=self.arrowhead_stroke_width,
        transform=self.arrowhead_transform,
    )
    transformation = self._get_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

arrowhead_length

arrowhead_length() -> float

Return the length of the single-headed arc arrowhead

Source code in src/momapy/core.py
1071
1072
1073
1074
1075
1076
1077
1078
def arrowhead_length(self) -> float:
    """Return the length of the single-headed arc arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return bbox.east().x

arrowhead_tip

arrowhead_tip() -> Point

Return the arrowhead tip anchor point of the single-headed arc

Source code in src/momapy/core.py
1080
1081
1082
1083
1084
1085
1086
1087
def arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the arrowhead tip anchor point of the single-headed arc"""
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.end_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

childless

childless() -> Self

Return a copy of the arc with no children

Source code in src/momapy/core.py
978
979
980
def childless(self) -> typing.Self:
    """Return a copy of the arc with no children"""
    return dataclasses.replace(self, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

end_point

end_point() -> Point

Return the ending point of the arc

Source code in src/momapy/core.py
974
975
976
def end_point(self) -> momapy.geometry.Point:
    """Return the ending point of the arc"""
    return self.points()[-1]

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

fraction

fraction(fraction: float) -> tuple[Point, float]

Return the position and angle on the arc at a given fraction (of the total arc length)

Source code in src/momapy/core.py
982
983
984
985
986
987
988
989
990
991
def fraction(self, fraction: float) -> tuple[momapy.geometry.Point, float]:
    """Return the position and angle on the arc at a given fraction (of the total arc length)"""
    current_length = 0
    length_to_reach = fraction * self.length()
    for segment in self.segments:
        current_length += segment.length()
        if current_length >= length_to_reach:
            break
    position, angle = segment.get_position_and_angle_at_fraction(fraction)
    return position, angle

length

length()

Return the total length of the arc path

Source code in src/momapy/core.py
966
967
968
def length(self):
    """Return the total length of the arc path"""
    return sum([segment.length() for segment in self.segments])

path_drawing_elements

path_drawing_elements() -> list[Path]

Return the drawing elements of the single-headed arc path

Source code in src/momapy/core.py
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
def path_drawing_elements(self) -> list[momapy.drawing.Path]:
    """Return the drawing elements of the single-headed arc path"""
    arrowhead_length = self.arrowhead_length()
    if len(self.segments) == 1:
        segment = (
            self.segments[0]
            .shortened(self.start_shorten, "start")
            .shortened(self.end_shorten + arrowhead_length, "end")
        )
        actions = [
            momapy.drawing.MoveTo(segment.p1),
            self._make_path_action_from_segment(segment),
        ]
    else:
        first_segment = self.segments[0].shortened(
            self.start_shorten, "start"
        )
        last_segment = self.segments[-1].shortened(
            self.end_shorten + arrowhead_length, "end"
        )
        actions = [
            momapy.drawing.MoveTo(first_segment.p1),
            self._make_path_action_from_segment(first_segment),
        ]
        for segment in self.segments[1:-1]:
            action = self._make_path_action_from_segment(segment)
            actions.append(action)
        actions.append(self._make_path_action_from_segment(last_segment))
    path = momapy.drawing.Path(
        actions=actions,
        class_=f"{type(self).__name__}_path",
        fill=self.path_fill,
        filter=self.path_filter,
        id_=f"{self.id_}_path",
        stroke=self.path_stroke,
        stroke_dasharray=self.path_stroke_dasharray,
        stroke_dashoffset=self.path_stroke_dashoffset,
        stroke_width=self.path_stroke_width,
        transform=self.path_transform,
    )
    return [path]

points

points() -> list[Point]

Return the points of the arc path

Source code in src/momapy/core.py
958
959
960
961
962
963
964
def points(self) -> list[momapy.geometry.Point]:
    """Return the points of the arc path"""
    points = []
    for segment in self.segments:
        points.append(segment.p1)
    points.append(segment.p2)
    return points

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_children

self_children() -> list[LayoutElement]

Return the self children of the arc

Source code in src/momapy/core.py
954
955
956
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the arc"""
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the single-headed arc

Source code in src/momapy/core.py
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the single-headed arc"""
    elements = (
        self.path_drawing_elements() + self.arrowhead_drawing_elements()
    )
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

start_point

start_point() -> Point

Return the starting point of the arc

Source code in src/momapy/core.py
970
971
972
def start_point(self) -> momapy.geometry.Point:
    """Return the starting point of the arc"""
    return self.points()[0]

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

Multimer dataclass

Multimer(
    *,
    id_: str = get_uuid4_as_str(),
    compartment: Compartment | None = None,
    label: str | None = None,
    state_variables: frozenset[StateVariable] = frozenset(),
    units_of_information: frozenset[
        UnitOfInformation
    ] = frozenset(),
    subunits: frozenset[Subunit] = frozenset(),
    cardinality: int | None = None
)

Bases: Complex

Base class for multimers

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'0bd525e6-0b55-4b96-b548-b050e134dd90'
compartment Compartment | None
None
label str | None
None
cardinality int | None
None

MultimerSubunit dataclass

MultimerSubunit(
    *,
    id_: str = get_uuid4_as_str(),
    label: str | None = None,
    state_variables: frozenset[StateVariable] = frozenset(),
    units_of_information: frozenset[
        UnitOfInformation
    ] = frozenset(),
    subunits: frozenset[Subunit] = frozenset(),
    cardinality: int | None = None
)

Bases: ComplexSubunit

Base class for multimer subunits

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'8fbd118f-98a0-4049-8bcd-18ae2313e662'
label str | None
None
cardinality int | None
None

NecessaryStimulation dataclass

NecessaryStimulation(
    *,
    id_: str = get_uuid4_as_str(),
    source: EntityPool | LogicalOperator,
    target: Process
)

Bases: Stimulation

Class for necessary stimulations

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'e3893a81-05ce-4e47-bbbf-bc4a46f94e73'
source EntityPool | LogicalOperator
required
target Process
required

NecessaryStimulationLayout dataclass

NecessaryStimulationLayout(
    path_fill: NoneValueType | Color | None = NoneValue,
    path_stroke: NoneValueType | Color | None = black,
    path_stroke_width: float | None = 1.25,
    arrowhead_fill: NoneValueType | Color | None = white,
    arrowhead_stroke: NoneValueType | Color | None = black,
    arrowhead_stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_shorten: float = 0.0,
    fill: NoneValueType | Color | None = None,
    filter: NoneValueType | Filter | None = None,
    path_filter: NoneValueType | Filter | None = None,
    path_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    path_stroke_dashoffset: float | None = None,
    path_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    stroke: NoneValueType | Color | None = None,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    stroke_width: float | None = None,
    segments: tuple[
        Segment | BezierCurve | EllipticalArc
    ] = tuple(),
    source: LayoutElement | None = None,
    start_shorten: float = 0.0,
    target: LayoutElement | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    arrowhead_filter: NoneValueType | Filter | None = None,
    arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    arrowhead_stroke_dashoffset: float | None = None,
    arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    arrowhead_bar_height: float = 12.0,
    arrowhead_sep: float = 3.0,
    arrowhead_triangle_height: float = 10.0,
    arrowhead_triangle_width: float = 10.0
)

Bases: SBGNSingleHeadedArc

Class for necessary stimulation layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'376c1d5b-054f-4214-9bc5-6da7106220db'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
end_shorten float

The length the end of the arc will be shorten by

0.0
fill NoneValueType | Color | None

The fill color of the arc

None
filter NoneValueType | Filter | None

The fill filter of the arc

None
path_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
path_filter NoneValueType | Filter | None

The path filter of the arc

None
path_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
path_stroke_dasharray NoneValueType | tuple[float] | None

The path stroke dasharray of the arc

None
path_stroke_dashoffset float | None

The path stroke dashoffset of the arc

None
path_stroke_width float | None
1.25
path_transform NoneValueType | tuple[Transformation] | None

The path transform of the arc

None
stroke NoneValueType | Color | None

The stroke color of the arc

None
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the arc

None
stroke_dashoffset float | None

The stroke dashoffset of the arc

None
stroke_width float | None

The stroke width of the arc

None
segments tuple[Union[Segment, BezierCurve, EllipticalArc]]

The path segments of the arc

<dynamic>
source LayoutElement | None

The source of the arc

None
start_shorten float

The length the start of the arc will be shorten by

0.0
target LayoutElement | None

The target of the arc

None
transform NoneValueType | tuple[Transformation] | None

The transform of the arc

None
arrowhead_fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
arrowhead_filter NoneValueType | Filter | None

The arrowhead filter of the arc

None
arrowhead_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
arrowhead_stroke_dasharray NoneValueType | tuple[float] | None

The arrowhead stroke dasharray of the arc

None
arrowhead_stroke_dashoffset float | None

The arrowhead stroke dashoffset of the arc

None
arrowhead_stroke_width float | None
1.25
arrowhead_transform NoneValueType | tuple[Transformation] | None

The arrowhead transform of the arc

None
arrowhead_bar_height float
12.0
arrowhead_sep float
3.0
arrowhead_triangle_height float
10.0
arrowhead_triangle_width float
10.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

arrowhead_base

Return the arrowhead base anchor point of the single-headed arc

arrowhead_bbox

Return the bounding box of the single-headed arc arrowhead

arrowhead_border

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.

arrowhead_drawing_elements

Return the drawing elements of the single-headed arc arrowhead

arrowhead_length

Return the length of the single-headed arc arrowhead

arrowhead_tip

Return the arrowhead tip anchor point of the single-headed arc

bbox

Compute and return the bounding box of the layout element

childless

Return a copy of the arc with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

end_point

Return the ending point of the arc

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

fraction

Return the position and angle on the arc at a given fraction (of the total arc length)

length

Return the total length of the arc path

path_drawing_elements

Return the drawing elements of the single-headed arc path

points

Return the points of the arc path

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_children

Return the self children of the arc

self_drawing_elements

Return the self drawing elements of the single-headed arc

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

start_point

Return the starting point of the arc

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

arrowhead_base

arrowhead_base() -> Point

Return the arrowhead base anchor point of the single-headed arc

Source code in src/momapy/core.py
1089
1090
1091
1092
1093
1094
1095
1096
1097
def arrowhead_base(self) -> momapy.geometry.Point:
    """Return the arrowhead base anchor point of the single-headed arc"""
    arrowhead_length = self.arrowhead_length()
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return self.arrowhead_tip() - (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.end_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

arrowhead_bbox

arrowhead_bbox() -> Bbox

Return the bounding box of the single-headed arc arrowhead

Source code in src/momapy/core.py
1099
1100
1101
1102
1103
def arrowhead_bbox(self) -> momapy.geometry.Bbox:
    """Return the bounding box of the single-headed arc arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.arrowhead_drawing_elements()
    )

arrowhead_border

arrowhead_border(point) -> Point

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
def arrowhead_border(self, point) -> momapy.geometry.Point:
    """Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """

    point = momapy.drawing.get_drawing_elements_border(
        self.arrowhead_drawing_elements(), point
    )
    if point is None:
        return self.arrowhead_tip()
    return point

arrowhead_drawing_elements

arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the single-headed arc arrowhead

Source code in src/momapy/core.py
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
def arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the single-headed arc arrowhead"""
    elements = self._arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_arrowhead",
        elements=elements,
        fill=self.arrowhead_fill,
        filter=self.arrowhead_filter,
        id_=f"{self.id_}_arrowhead",
        stroke=self.arrowhead_stroke,
        stroke_dasharray=self.arrowhead_stroke_dasharray,
        stroke_dashoffset=self.arrowhead_stroke_dashoffset,
        stroke_width=self.arrowhead_stroke_width,
        transform=self.arrowhead_transform,
    )
    transformation = self._get_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

arrowhead_length

arrowhead_length() -> float

Return the length of the single-headed arc arrowhead

Source code in src/momapy/core.py
1071
1072
1073
1074
1075
1076
1077
1078
def arrowhead_length(self) -> float:
    """Return the length of the single-headed arc arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return bbox.east().x

arrowhead_tip

arrowhead_tip() -> Point

Return the arrowhead tip anchor point of the single-headed arc

Source code in src/momapy/core.py
1080
1081
1082
1083
1084
1085
1086
1087
def arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the arrowhead tip anchor point of the single-headed arc"""
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.end_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

childless

childless() -> Self

Return a copy of the arc with no children

Source code in src/momapy/core.py
978
979
980
def childless(self) -> typing.Self:
    """Return a copy of the arc with no children"""
    return dataclasses.replace(self, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

end_point

end_point() -> Point

Return the ending point of the arc

Source code in src/momapy/core.py
974
975
976
def end_point(self) -> momapy.geometry.Point:
    """Return the ending point of the arc"""
    return self.points()[-1]

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

fraction

fraction(fraction: float) -> tuple[Point, float]

Return the position and angle on the arc at a given fraction (of the total arc length)

Source code in src/momapy/core.py
982
983
984
985
986
987
988
989
990
991
def fraction(self, fraction: float) -> tuple[momapy.geometry.Point, float]:
    """Return the position and angle on the arc at a given fraction (of the total arc length)"""
    current_length = 0
    length_to_reach = fraction * self.length()
    for segment in self.segments:
        current_length += segment.length()
        if current_length >= length_to_reach:
            break
    position, angle = segment.get_position_and_angle_at_fraction(fraction)
    return position, angle

length

length()

Return the total length of the arc path

Source code in src/momapy/core.py
966
967
968
def length(self):
    """Return the total length of the arc path"""
    return sum([segment.length() for segment in self.segments])

path_drawing_elements

path_drawing_elements() -> list[Path]

Return the drawing elements of the single-headed arc path

Source code in src/momapy/core.py
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
def path_drawing_elements(self) -> list[momapy.drawing.Path]:
    """Return the drawing elements of the single-headed arc path"""
    arrowhead_length = self.arrowhead_length()
    if len(self.segments) == 1:
        segment = (
            self.segments[0]
            .shortened(self.start_shorten, "start")
            .shortened(self.end_shorten + arrowhead_length, "end")
        )
        actions = [
            momapy.drawing.MoveTo(segment.p1),
            self._make_path_action_from_segment(segment),
        ]
    else:
        first_segment = self.segments[0].shortened(
            self.start_shorten, "start"
        )
        last_segment = self.segments[-1].shortened(
            self.end_shorten + arrowhead_length, "end"
        )
        actions = [
            momapy.drawing.MoveTo(first_segment.p1),
            self._make_path_action_from_segment(first_segment),
        ]
        for segment in self.segments[1:-1]:
            action = self._make_path_action_from_segment(segment)
            actions.append(action)
        actions.append(self._make_path_action_from_segment(last_segment))
    path = momapy.drawing.Path(
        actions=actions,
        class_=f"{type(self).__name__}_path",
        fill=self.path_fill,
        filter=self.path_filter,
        id_=f"{self.id_}_path",
        stroke=self.path_stroke,
        stroke_dasharray=self.path_stroke_dasharray,
        stroke_dashoffset=self.path_stroke_dashoffset,
        stroke_width=self.path_stroke_width,
        transform=self.path_transform,
    )
    return [path]

points

points() -> list[Point]

Return the points of the arc path

Source code in src/momapy/core.py
958
959
960
961
962
963
964
def points(self) -> list[momapy.geometry.Point]:
    """Return the points of the arc path"""
    points = []
    for segment in self.segments:
        points.append(segment.p1)
    points.append(segment.p2)
    return points

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_children

self_children() -> list[LayoutElement]

Return the self children of the arc

Source code in src/momapy/core.py
954
955
956
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the arc"""
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the single-headed arc

Source code in src/momapy/core.py
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the single-headed arc"""
    elements = (
        self.path_drawing_elements() + self.arrowhead_drawing_elements()
    )
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

start_point

start_point() -> Point

Return the starting point of the arc

Source code in src/momapy/core.py
970
971
972
def start_point(self) -> momapy.geometry.Point:
    """Return the starting point of the arc"""
    return self.points()[0]

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

NotOperator dataclass

NotOperator(
    *,
    id_: str = get_uuid4_as_str(),
    inputs: frozenset[LogicalOperatorInput] = frozenset()
)

Bases: LogicalOperator

Class for not operators

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'1cdd6c6f-bdb1-4891-a29c-9a8a957f200a'

NotOperatorLayout dataclass

NotOperatorLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 30.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 30.0,
    direction: Direction = HORIZONTAL,
    left_to_right: bool = True,
    left_connector_length: float = 10.0,
    right_connector_length: float = 10.0,
    left_connector_stroke: (
        NoneValueType | Color | None
    ) = None,
    left_connector_stroke_width: float | None = None,
    left_connector_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    left_connector_stroke_dashoffset: float | None = None,
    left_connector_fill: (
        NoneValueType | Color | None
    ) = None,
    left_connector_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    left_connector_filter: (
        NoneValueType | Filter | None
    ) = None,
    right_connector_stroke: (
        NoneValueType | Color | None
    ) = None,
    right_connector_stroke_width: float | None = None,
    right_connector_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    right_connector_stroke_dashoffset: float | None = None,
    right_connector_fill: (
        NoneValueType | Color | None
    ) = None,
    right_connector_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    right_connector_filter: (
        NoneValueType | Filter | None
    ) = None
)

Bases: _ConnectorsMixin, _SimpleMixin, _TextMixin, SBGNNode

Class for not operator layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'756c38fe-ae12-4c18-b0a5-50c526d61690'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
30.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
30.0
direction Direction
<Direction.HORIZONTAL: 1>
left_to_right bool
True
left_connector_length float
10.0
right_connector_length float
10.0
left_connector_stroke NoneValueType | Color | None
None
left_connector_stroke_width float | None
None
left_connector_stroke_dasharray NoneValueType | tuple[float] | None
None
left_connector_stroke_dashoffset float | None
None
left_connector_fill NoneValueType | Color | None
None
left_connector_transform NoneValueType | tuple[Transformation] | None
None
left_connector_filter NoneValueType | Filter | None
None
right_connector_stroke NoneValueType | Color | None
None
right_connector_stroke_width float | None
None
right_connector_stroke_dasharray NoneValueType | tuple[float] | None
None
right_connector_stroke_dashoffset float | None
None
right_connector_fill NoneValueType | Color | None
None
right_connector_transform NoneValueType | tuple[Transformation] | None
None
right_connector_filter NoneValueType | Filter | None
None

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
791
792
793
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

NucleicAcidFeature dataclass

NucleicAcidFeature(
    *,
    id_: str = get_uuid4_as_str(),
    compartment: Compartment | None = None,
    label: str | None = None,
    state_variables: frozenset[StateVariable] = frozenset(),
    units_of_information: frozenset[
        UnitOfInformation
    ] = frozenset()
)

Bases: EntityPool

Class for nucleic acid features

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'8066843a-00c9-4087-a5b4-661402c50eea'
compartment Compartment | None
None
label str | None
None

NucleicAcidFeatureLayout dataclass

NucleicAcidFeatureLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 30.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 60.0,
    rounded_corners: float = 5.0
)

Bases: _SimpleMixin, SBGNNode

Class for nucleic acid feature layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'9aafad97-027b-4eee-b65c-5b2d3e2cbc58'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
30.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
60.0
rounded_corners float
5.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
791
792
793
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

NucleicAcidFeatureMultimer dataclass

NucleicAcidFeatureMultimer(
    *,
    id_: str = get_uuid4_as_str(),
    compartment: Compartment | None = None,
    label: str | None = None,
    state_variables: frozenset[StateVariable] = frozenset(),
    units_of_information: frozenset[
        UnitOfInformation
    ] = frozenset(),
    subunits: frozenset[Subunit] = frozenset(),
    cardinality: int | None = None
)

Bases: Multimer

Class for nucleic acid feature multimers

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'72a78b2d-7b21-4288-a7b0-f83720bc2ca3'
compartment Compartment | None
None
label str | None
None
cardinality int | None
None

NucleicAcidFeatureMultimerLayout dataclass

NucleicAcidFeatureMultimerLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    offset: float = 3.0,
    subunits_stroke: (
        tuple[NoneValueType | Color] | None
    ) = None,
    subunits_stroke_width: (
        tuple[NoneValueType | float] | None
    ) = None,
    subunits_stroke_dasharray: (
        tuple[NoneValueType | tuple[float]] | None
    ) = None,
    subunits_stroke_dashoffset: tuple[float] | None = None,
    subunits_fill: (
        tuple[NoneValueType | Color] | None
    ) = None,
    subunits_transform: (
        tuple[NoneValueType | tuple[Transformation]] | None
    ) = None,
    subunits_filter: (
        tuple[NoneValueType | Filter] | None
    ) = None,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 30.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 60.0,
    rounded_corners: float = 5.0
)

Bases: _MultiMixin, SBGNNode

Class for nucleic acid feature multimer layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'aec4d54c-4eda-4b94-af9a-53444b2b814b'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
30.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
60.0
offset float
3.0
subunits_stroke tuple[Union[NoneValueType, Color]] | None
None
subunits_stroke_width tuple[Union[NoneValueType, float]] | None
None
subunits_stroke_dasharray tuple[Union[NoneValueType, tuple[float]]] | None
None
subunits_stroke_dashoffset tuple[float] | None
None
subunits_fill tuple[Union[NoneValueType, Color]] | None
None
subunits_transform tuple[Union[NoneValueType, tuple[Transformation]]] | None
None
subunits_filter tuple[Union[NoneValueType, Filter]] | None
None
rounded_corners float
5.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

NucleicAcidFeatureMultimerSubunit dataclass

NucleicAcidFeatureMultimerSubunit(
    *,
    id_: str = get_uuid4_as_str(),
    label: str | None = None,
    state_variables: frozenset[StateVariable] = frozenset(),
    units_of_information: frozenset[
        UnitOfInformation
    ] = frozenset(),
    subunits: frozenset[Subunit] = frozenset(),
    cardinality: int | None = None
)

Bases: MultimerSubunit

Class for nucleic acid feature multimer subunits

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'bef40879-44a3-4638-a904-053011f3ae0e'
label str | None
None
cardinality int | None
None

NucleicAcidFeatureMultimerSubunitLayout dataclass

NucleicAcidFeatureMultimerSubunitLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    offset: float = 3.0,
    subunits_stroke: (
        tuple[NoneValueType | Color] | None
    ) = None,
    subunits_stroke_width: (
        tuple[NoneValueType | float] | None
    ) = None,
    subunits_stroke_dasharray: (
        tuple[NoneValueType | tuple[float]] | None
    ) = None,
    subunits_stroke_dashoffset: tuple[float] | None = None,
    subunits_fill: (
        tuple[NoneValueType | Color] | None
    ) = None,
    subunits_transform: (
        tuple[NoneValueType | tuple[Transformation]] | None
    ) = None,
    subunits_filter: (
        tuple[NoneValueType | Filter] | None
    ) = None,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 30.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 60.0,
    rounded_corners: float = 5.0
)

Bases: _MultiMixin, SBGNNode

Class for nucleic acid feature multimer subunit layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'6b4a1dc8-4d8d-468f-8814-7cacf7429b25'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
30.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
60.0
offset float
3.0
subunits_stroke tuple[Union[NoneValueType, Color]] | None
None
subunits_stroke_width tuple[Union[NoneValueType, float]] | None
None
subunits_stroke_dasharray tuple[Union[NoneValueType, tuple[float]]] | None
None
subunits_stroke_dashoffset tuple[float] | None
None
subunits_fill tuple[Union[NoneValueType, Color]] | None
None
subunits_transform tuple[Union[NoneValueType, tuple[Transformation]]] | None
None
subunits_filter tuple[Union[NoneValueType, Filter]] | None
None
rounded_corners float
5.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

NucleicAcidFeatureSubunit dataclass

NucleicAcidFeatureSubunit(
    *,
    id_: str = get_uuid4_as_str(),
    label: str | None = None,
    state_variables: frozenset[StateVariable] = frozenset(),
    units_of_information: frozenset[
        UnitOfInformation
    ] = frozenset()
)

Bases: Subunit

Class for nucleic acid feature subunits

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'66fecbc8-7657-4c51-b62c-e93164f6b0ea'
label str | None
None

NucleicAcidFeatureSubunitLayout dataclass

NucleicAcidFeatureSubunitLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 30.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 60.0,
    rounded_corners: float = 5.0
)

Bases: _SimpleMixin, SBGNNode

Class for nucleic acid feature subunit layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'56f4cf8a-8d4d-4bba-b5b7-45fc0d25ced3'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
30.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
60.0
rounded_corners float
5.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
791
792
793
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

OmittedProcess dataclass

OmittedProcess(
    *,
    id_: str = get_uuid4_as_str(),
    reactants: frozenset[Reactant] = frozenset(),
    products: frozenset[Product] = frozenset(),
    reversible: bool = False
)

Bases: GenericProcess

Class for omitted processes

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'e087ed07-f724-47e5-ac99-c9be091006cf'
reversible bool
False

OmittedProcessLayout dataclass

OmittedProcessLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 20.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 20.0,
    direction: Direction = HORIZONTAL,
    left_to_right: bool = True,
    left_connector_length: float = 10.0,
    right_connector_length: float = 10.0,
    left_connector_stroke: (
        NoneValueType | Color | None
    ) = None,
    left_connector_stroke_width: float | None = None,
    left_connector_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    left_connector_stroke_dashoffset: float | None = None,
    left_connector_fill: (
        NoneValueType | Color | None
    ) = None,
    left_connector_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    left_connector_filter: (
        NoneValueType | Filter | None
    ) = None,
    right_connector_stroke: (
        NoneValueType | Color | None
    ) = None,
    right_connector_stroke_width: float | None = None,
    right_connector_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    right_connector_stroke_dashoffset: float | None = None,
    right_connector_fill: (
        NoneValueType | Color | None
    ) = None,
    right_connector_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    right_connector_filter: (
        NoneValueType | Filter | None
    ) = None
)

Bases: _ConnectorsMixin, _SimpleMixin, _TextMixin, SBGNNode

Class for omitted process layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'dc2bd99b-1fcf-4f90-9a2c-923b624edf49'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
20.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
20.0
direction Direction
<Direction.HORIZONTAL: 1>
left_to_right bool
True
left_connector_length float
10.0
right_connector_length float
10.0
left_connector_stroke NoneValueType | Color | None
None
left_connector_stroke_width float | None
None
left_connector_stroke_dasharray NoneValueType | tuple[float] | None
None
left_connector_stroke_dashoffset float | None
None
left_connector_fill NoneValueType | Color | None
None
left_connector_transform NoneValueType | tuple[Transformation] | None
None
left_connector_filter NoneValueType | Filter | None
None
right_connector_stroke NoneValueType | Color | None
None
right_connector_stroke_width float | None
None
right_connector_stroke_dasharray NoneValueType | tuple[float] | None
None
right_connector_stroke_dashoffset float | None
None
right_connector_fill NoneValueType | Color | None
None
right_connector_transform NoneValueType | tuple[Transformation] | None
None
right_connector_filter NoneValueType | Filter | None
None

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
791
792
793
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

OrOperator dataclass

OrOperator(
    *,
    id_: str = get_uuid4_as_str(),
    inputs: frozenset[LogicalOperatorInput] = frozenset()
)

Bases: LogicalOperator

Class for or operators

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'bcf3e502-739d-4bbb-b1fd-4d06bb268d60'

OrOperatorLayout dataclass

OrOperatorLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 30.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 30.0,
    direction: Direction = HORIZONTAL,
    left_to_right: bool = True,
    left_connector_length: float = 10.0,
    right_connector_length: float = 10.0,
    left_connector_stroke: (
        NoneValueType | Color | None
    ) = None,
    left_connector_stroke_width: float | None = None,
    left_connector_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    left_connector_stroke_dashoffset: float | None = None,
    left_connector_fill: (
        NoneValueType | Color | None
    ) = None,
    left_connector_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    left_connector_filter: (
        NoneValueType | Filter | None
    ) = None,
    right_connector_stroke: (
        NoneValueType | Color | None
    ) = None,
    right_connector_stroke_width: float | None = None,
    right_connector_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    right_connector_stroke_dashoffset: float | None = None,
    right_connector_fill: (
        NoneValueType | Color | None
    ) = None,
    right_connector_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    right_connector_filter: (
        NoneValueType | Filter | None
    ) = None
)

Bases: _ConnectorsMixin, _SimpleMixin, _TextMixin, SBGNNode

Class for or operator layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'dcb8b9f2-4fea-4068-9325-a33e94d3e241'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
30.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
30.0
direction Direction
<Direction.HORIZONTAL: 1>
left_to_right bool
True
left_connector_length float
10.0
right_connector_length float
10.0
left_connector_stroke NoneValueType | Color | None
None
left_connector_stroke_width float | None
None
left_connector_stroke_dasharray NoneValueType | tuple[float] | None
None
left_connector_stroke_dashoffset float | None
None
left_connector_fill NoneValueType | Color | None
None
left_connector_transform NoneValueType | tuple[Transformation] | None
None
left_connector_filter NoneValueType | Filter | None
None
right_connector_stroke NoneValueType | Color | None
None
right_connector_stroke_width float | None
None
right_connector_stroke_dasharray NoneValueType | tuple[float] | None
None
right_connector_stroke_dashoffset float | None
None
right_connector_fill NoneValueType | Color | None
None
right_connector_transform NoneValueType | tuple[Transformation] | None
None
right_connector_filter NoneValueType | Filter | None
None

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
791
792
793
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

PerturbingAgent dataclass

PerturbingAgent(
    *,
    id_: str = get_uuid4_as_str(),
    compartment: Compartment | None = None,
    label: str | None = None
)

Bases: EntityPool

Class for perturbing agents

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'eaeb3960-d221-41e3-908f-c5bc2888b7a4'
compartment Compartment | None
None
label str | None
None

PerturbingAgentLayout dataclass

PerturbingAgentLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 30.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 60.0,
    angle: float = 70.0
)

Bases: _SimpleMixin, SBGNNode

Class for perturbing agent layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'b118e33c-b917-4d3a-97dc-f486f934e23c'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
30.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
60.0
angle float
70.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
angle float

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle class-attribute instance-attribute

angle: float = 70.0

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
791
792
793
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

Phenotype dataclass

Phenotype(
    *,
    id_: str = get_uuid4_as_str(),
    label: str | None = None
)

Bases: Process

Class for phenotypes

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'dca09d63-b0ae-43ad-a578-37bd9b1ec16b'
label str | None
None

PhenotypeLayout dataclass

PhenotypeLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 30.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 60.0,
    angle: float = 70.0
)

Bases: _SimpleMixin, SBGNNode

Class for phenotype layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'bd5c356a-45bc-4da4-8a49-986bbec578fc'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
30.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
60.0
angle float
70.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
angle float

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle class-attribute instance-attribute

angle: float = 70.0

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
791
792
793
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

Process dataclass

Process(*, id_: str = get_uuid4_as_str())

Bases: SBGNModelElement

Base class for processes

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'ca548e0a-ef94-465d-81ae-2350fbd2cd94'

Product dataclass

Product(
    *,
    id_: str = get_uuid4_as_str(),
    element: EntityPool,
    stoichiometry: int | None = None
)

Bases: FluxRole

Class for products

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'73a396f9-339c-4f72-909b-5cf49145aa2c'
element EntityPool
required
stoichiometry int | None
None

ProductionLayout dataclass

ProductionLayout(
    path_fill: NoneValueType | Color | None = NoneValue,
    path_stroke: NoneValueType | Color | None = black,
    path_stroke_width: float | None = 1.25,
    arrowhead_stroke: NoneValueType | Color | None = black,
    arrowhead_stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_shorten: float = 0.0,
    fill: NoneValueType | Color | None = None,
    filter: NoneValueType | Filter | None = None,
    path_filter: NoneValueType | Filter | None = None,
    path_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    path_stroke_dashoffset: float | None = None,
    path_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    stroke: NoneValueType | Color | None = None,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    stroke_width: float | None = None,
    segments: tuple[
        Segment | BezierCurve | EllipticalArc
    ] = tuple(),
    source: LayoutElement | None = None,
    start_shorten: float = 0.0,
    target: LayoutElement | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    arrowhead_fill: NoneValueType | Color | None = black,
    arrowhead_filter: NoneValueType | Filter | None = None,
    arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    arrowhead_stroke_dashoffset: float | None = None,
    arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    arrowhead_height: float = 10.0,
    arrowhead_width: float = 10.0
)

Bases: SBGNSingleHeadedArc

Class for production layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'6e4ae224-7ab6-454d-b0f1-037e0c369bc8'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
end_shorten float

The length the end of the arc will be shorten by

0.0
fill NoneValueType | Color | None

The fill color of the arc

None
filter NoneValueType | Filter | None

The fill filter of the arc

None
path_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
path_filter NoneValueType | Filter | None

The path filter of the arc

None
path_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
path_stroke_dasharray NoneValueType | tuple[float] | None

The path stroke dasharray of the arc

None
path_stroke_dashoffset float | None

The path stroke dashoffset of the arc

None
path_stroke_width float | None
1.25
path_transform NoneValueType | tuple[Transformation] | None

The path transform of the arc

None
stroke NoneValueType | Color | None

The stroke color of the arc

None
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the arc

None
stroke_dashoffset float | None

The stroke dashoffset of the arc

None
stroke_width float | None

The stroke width of the arc

None
segments tuple[Union[Segment, BezierCurve, EllipticalArc]]

The path segments of the arc

<dynamic>
source LayoutElement | None

The source of the arc

None
start_shorten float

The length the start of the arc will be shorten by

0.0
target LayoutElement | None

The target of the arc

None
transform NoneValueType | tuple[Transformation] | None

The transform of the arc

None
arrowhead_fill NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
arrowhead_filter NoneValueType | Filter | None

The arrowhead filter of the arc

None
arrowhead_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
arrowhead_stroke_dasharray NoneValueType | tuple[float] | None

The arrowhead stroke dasharray of the arc

None
arrowhead_stroke_dashoffset float | None

The arrowhead stroke dashoffset of the arc

None
arrowhead_stroke_width float | None
1.25
arrowhead_transform NoneValueType | tuple[Transformation] | None

The arrowhead transform of the arc

None
arrowhead_height float
10.0
arrowhead_width float
10.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

arrowhead_base

Return the arrowhead base anchor point of the single-headed arc

arrowhead_bbox

Return the bounding box of the single-headed arc arrowhead

arrowhead_border

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.

arrowhead_drawing_elements

Return the drawing elements of the single-headed arc arrowhead

arrowhead_length

Return the length of the single-headed arc arrowhead

arrowhead_tip

Return the arrowhead tip anchor point of the single-headed arc

bbox

Compute and return the bounding box of the layout element

childless

Return a copy of the arc with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

end_point

Return the ending point of the arc

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

fraction

Return the position and angle on the arc at a given fraction (of the total arc length)

length

Return the total length of the arc path

path_drawing_elements

Return the drawing elements of the single-headed arc path

points

Return the points of the arc path

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_children

Return the self children of the arc

self_drawing_elements

Return the self drawing elements of the single-headed arc

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

start_point

Return the starting point of the arc

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

arrowhead_base

arrowhead_base() -> Point

Return the arrowhead base anchor point of the single-headed arc

Source code in src/momapy/core.py
1089
1090
1091
1092
1093
1094
1095
1096
1097
def arrowhead_base(self) -> momapy.geometry.Point:
    """Return the arrowhead base anchor point of the single-headed arc"""
    arrowhead_length = self.arrowhead_length()
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return self.arrowhead_tip() - (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.end_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

arrowhead_bbox

arrowhead_bbox() -> Bbox

Return the bounding box of the single-headed arc arrowhead

Source code in src/momapy/core.py
1099
1100
1101
1102
1103
def arrowhead_bbox(self) -> momapy.geometry.Bbox:
    """Return the bounding box of the single-headed arc arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.arrowhead_drawing_elements()
    )

arrowhead_border

arrowhead_border(point) -> Point

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
def arrowhead_border(self, point) -> momapy.geometry.Point:
    """Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """

    point = momapy.drawing.get_drawing_elements_border(
        self.arrowhead_drawing_elements(), point
    )
    if point is None:
        return self.arrowhead_tip()
    return point

arrowhead_drawing_elements

arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the single-headed arc arrowhead

Source code in src/momapy/core.py
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
def arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the single-headed arc arrowhead"""
    elements = self._arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_arrowhead",
        elements=elements,
        fill=self.arrowhead_fill,
        filter=self.arrowhead_filter,
        id_=f"{self.id_}_arrowhead",
        stroke=self.arrowhead_stroke,
        stroke_dasharray=self.arrowhead_stroke_dasharray,
        stroke_dashoffset=self.arrowhead_stroke_dashoffset,
        stroke_width=self.arrowhead_stroke_width,
        transform=self.arrowhead_transform,
    )
    transformation = self._get_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

arrowhead_length

arrowhead_length() -> float

Return the length of the single-headed arc arrowhead

Source code in src/momapy/core.py
1071
1072
1073
1074
1075
1076
1077
1078
def arrowhead_length(self) -> float:
    """Return the length of the single-headed arc arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return bbox.east().x

arrowhead_tip

arrowhead_tip() -> Point

Return the arrowhead tip anchor point of the single-headed arc

Source code in src/momapy/core.py
1080
1081
1082
1083
1084
1085
1086
1087
def arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the arrowhead tip anchor point of the single-headed arc"""
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.end_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

childless

childless() -> Self

Return a copy of the arc with no children

Source code in src/momapy/core.py
978
979
980
def childless(self) -> typing.Self:
    """Return a copy of the arc with no children"""
    return dataclasses.replace(self, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

end_point

end_point() -> Point

Return the ending point of the arc

Source code in src/momapy/core.py
974
975
976
def end_point(self) -> momapy.geometry.Point:
    """Return the ending point of the arc"""
    return self.points()[-1]

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

fraction

fraction(fraction: float) -> tuple[Point, float]

Return the position and angle on the arc at a given fraction (of the total arc length)

Source code in src/momapy/core.py
982
983
984
985
986
987
988
989
990
991
def fraction(self, fraction: float) -> tuple[momapy.geometry.Point, float]:
    """Return the position and angle on the arc at a given fraction (of the total arc length)"""
    current_length = 0
    length_to_reach = fraction * self.length()
    for segment in self.segments:
        current_length += segment.length()
        if current_length >= length_to_reach:
            break
    position, angle = segment.get_position_and_angle_at_fraction(fraction)
    return position, angle

length

length()

Return the total length of the arc path

Source code in src/momapy/core.py
966
967
968
def length(self):
    """Return the total length of the arc path"""
    return sum([segment.length() for segment in self.segments])

path_drawing_elements

path_drawing_elements() -> list[Path]

Return the drawing elements of the single-headed arc path

Source code in src/momapy/core.py
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
def path_drawing_elements(self) -> list[momapy.drawing.Path]:
    """Return the drawing elements of the single-headed arc path"""
    arrowhead_length = self.arrowhead_length()
    if len(self.segments) == 1:
        segment = (
            self.segments[0]
            .shortened(self.start_shorten, "start")
            .shortened(self.end_shorten + arrowhead_length, "end")
        )
        actions = [
            momapy.drawing.MoveTo(segment.p1),
            self._make_path_action_from_segment(segment),
        ]
    else:
        first_segment = self.segments[0].shortened(
            self.start_shorten, "start"
        )
        last_segment = self.segments[-1].shortened(
            self.end_shorten + arrowhead_length, "end"
        )
        actions = [
            momapy.drawing.MoveTo(first_segment.p1),
            self._make_path_action_from_segment(first_segment),
        ]
        for segment in self.segments[1:-1]:
            action = self._make_path_action_from_segment(segment)
            actions.append(action)
        actions.append(self._make_path_action_from_segment(last_segment))
    path = momapy.drawing.Path(
        actions=actions,
        class_=f"{type(self).__name__}_path",
        fill=self.path_fill,
        filter=self.path_filter,
        id_=f"{self.id_}_path",
        stroke=self.path_stroke,
        stroke_dasharray=self.path_stroke_dasharray,
        stroke_dashoffset=self.path_stroke_dashoffset,
        stroke_width=self.path_stroke_width,
        transform=self.path_transform,
    )
    return [path]

points

points() -> list[Point]

Return the points of the arc path

Source code in src/momapy/core.py
958
959
960
961
962
963
964
def points(self) -> list[momapy.geometry.Point]:
    """Return the points of the arc path"""
    points = []
    for segment in self.segments:
        points.append(segment.p1)
    points.append(segment.p2)
    return points

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_children

self_children() -> list[LayoutElement]

Return the self children of the arc

Source code in src/momapy/core.py
954
955
956
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the arc"""
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the single-headed arc

Source code in src/momapy/core.py
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the single-headed arc"""
    elements = (
        self.path_drawing_elements() + self.arrowhead_drawing_elements()
    )
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

start_point

start_point() -> Point

Return the starting point of the arc

Source code in src/momapy/core.py
970
971
972
def start_point(self) -> momapy.geometry.Point:
    """Return the starting point of the arc"""
    return self.points()[0]

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

Reactant dataclass

Reactant(
    *,
    id_: str = get_uuid4_as_str(),
    element: EntityPool,
    stoichiometry: int | None = None
)

Bases: FluxRole

Class for reactants

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'2c6ed4ec-06f9-4ca7-8695-40c5544785ae'
element EntityPool
required
stoichiometry int | None
None

SBGNPDLayout dataclass

SBGNPDLayout(
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    fill: NoneValueType | Color | None = white,
    filter: NoneValueType | Filter | None = None,
    height: float,
    label: TextLayout | None = None,
    position: Point,
    stroke: NoneValueType | Color | None = None,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    stroke_width: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = None
)

Bases: SBGNLayout

Class for SBGN-PD layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'dd7f5ba3-a382-46cc-b8a0-5238f91d63e9'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float

The height of the node

required
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None

The stroke color of the node

None
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None

The stroke width of the node

None
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float

The stroke width of the node

None

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

is_sublayout

Return true if another given layout is a sublayout of the layout, false otherwise

label_center

Return the label center anchor of the node

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

is_sublayout

is_sublayout(other, flattened=False, unordered=False)

Return true if another given layout is a sublayout of the layout, false otherwise

Source code in src/momapy/core.py
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
def is_sublayout(self, other, flattened=False, unordered=False):
    """Return `true` if another given layout is a sublayout of the layout, `false` otherwise"""

    def _is_sublist(list1, list2, unordered=False) -> bool:
        if not unordered:
            i = 0
            for elem1 in list1:
                elem2 = list2[i]
                while elem2 != elem1 and i < len(list2) - 1:
                    i += 1
                    elem2 = list2[i]
                if not elem2 == elem1:
                    return False
                i += 1
        else:
            dlist1 = collections.defaultdict(int)
            dlist2 = collections.defaultdict(int)
            for elem1 in list1:
                dlist1[elem1] += 1
            for elem2 in list2:
                dlist2[elem2] += 1
            for elem in dlist1:
                if dlist1[elem] > dlist2[elem]:
                    return False
        return True

    if self.childless() != other.childless():
        return False
    if flattened:
        return _is_sublist(
            self.flattened()[1:],
            other.flattened()[1:],
            unordered=unordered,
        )
    return _is_sublist(
        self.children(), other.children(), unordered=unordered
    )

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
791
792
793
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

SBGNPDLayoutBuilder module-attribute

SBGNPDLayoutBuilder = get_or_make_builder_cls(SBGNPDLayout)

Class for SBGN-PD layout builders

SBGNPDMap dataclass

SBGNPDMap(
    *,
    id_: str = get_uuid4_as_str(),
    model: SBGNPDModel,
    layout: SBGNPDLayout,
    layout_model_mapping: LayoutModelMapping | None = None
)

Bases: SBGNMap

Class for SBGN-PD maps

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'6daf3565-a3f7-4d28-97e4-7f4308f3c069'
model SBGNPDModel
None
layout SBGNPDLayout
None
layout_model_mapping LayoutModelMapping | None

The layout model mapping of the map

None

Methods:

Name Description
get_mapping

Return the layout elements mapped to the given model element

is_submap

Return true if another given map is a submap of the Map, false otherwise

get_mapping

get_mapping(
    key: (
        ModelElement | _MappingElementType | _MappingKeyType
    ),
    expand: bool = True,
    unpack: bool = False,
)

Return the layout elements mapped to the given model element

Source code in src/momapy/core.py
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
def get_mapping(
    self,
    key: ModelElement | _MappingElementType | _MappingKeyType,
    expand: bool = True,
    unpack: bool = False,
):
    """Return the layout elements mapped to the given model element"""
    return self.layout_model_mapping.get_mapping(
        key=key, expand=expand, unpack=unpack
    )

is_submap

is_submap(other)

Return true if another given map is a submap of the Map, false otherwise

Source code in src/momapy/core.py
1768
1769
1770
1771
1772
1773
1774
1775
1776
def is_submap(self, other):
    """Return `true` if another given map is a submap of the `Map`, `false` otherwise"""
    return (
        self.model.is_submodel(other.model)
        and self.layout.is_sublayout(other.layout)
        and self.layout_model_mapping.is_submapping(
            other.layout_model_mapping
        )
    )

SBGNPDMapBuilder module-attribute

SBGNPDMapBuilder = get_or_make_builder_cls(
    SBGNPDMap,
    builder_namespace={
        "new_model": _sbgnpd_map_builder_new_model,
        "new_layout": _sbgnpd_map_builder_new_layout,
    },
)

Class for SBGN-PD map builders

SBGNPDModel dataclass

SBGNPDModel(
    *,
    id_: str = get_uuid4_as_str(),
    entity_pools: frozenset[EntityPool] = frozenset(),
    processes: frozenset[Process] = frozenset(),
    compartments: frozenset[Compartment] = frozenset(),
    modulations: frozenset[Modulation] = frozenset(),
    logical_operators: frozenset[
        LogicalOperator
    ] = frozenset(),
    equivalence_operators: frozenset[
        EquivalenceOperator
    ] = frozenset(),
    submaps: frozenset[Submap] = frozenset(),
    tags: frozenset[Tag] = frozenset()
)

Bases: SBGNModel

Class for SBGN-PD models

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'324fe142-8cb0-4186-a2c2-38465c9926c6'

Methods:

Name Description
is_ovav

Return true if the SBGN-PD model respects the Once a Variable Always a Variable (OVAV) rule, false otherwise

is_submodel

Return true if another given SBGN-PD model is a submodel of the SBGN-PD model, false otherwise

is_ovav

is_ovav() -> bool

Return true if the SBGN-PD model respects the Once a Variable Always a Variable (OVAV) rule, false otherwise

Source code in src/momapy/sbgn/pd.py
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
def is_ovav(self) -> bool:
    """Return `true` if the SBGN-PD model respects the Once a Variable Always a Variable (OVAV) rule, `false` otherwise"""
    subunit_cls_entity_pool_cls_mapping = {
        MacromoleculeSubunit: Macromolecule,
        NucleicAcidFeatureSubunit: NucleicAcidFeature,
        ComplexSubunit: Complex,
        SimpleChemicalSubunit: SimpleChemical,
        MacromoleculeMultimerSubunit: MacromoleculeMultimer,
        NucleicAcidFeatureMultimerSubunit: NucleicAcidFeatureMultimer,
        ComplexMultimerSubunit: ComplexMultimer,
        SimpleChemicalMultimerSubunit: SimpleChemicalMultimer,
    }

    def _check_entities(entities, entity_variables_mapping=None):
        if entity_variables_mapping is None:
            entity_variables_mapping = {}
        for entity in entities:
            if hasattr(entity, "state_variables"):
                variables = set(
                    [sv.variable for sv in entity.state_variables]
                )
                attributes = []
                for field in dataclasses.fields(entity):
                    if field.name != "state_variables":
                        attributes.append(field.name)
                args = {attr: getattr(entity, attr) for attr in attributes}
                if isinstance(entity, Subunit):
                    cls = subunit_cls_entity_pool_cls_mapping[type(entity)]
                else:
                    cls = type(entity)
                entity_no_svs = cls(**args)
                if entity_no_svs not in entity_variables_mapping:
                    entity_variables_mapping[entity_no_svs] = variables
                else:
                    if (
                        entity_variables_mapping[entity_no_svs]
                        != variables
                    ):
                        return False
            if hasattr(entity, "subunits"):
                is_ovav = _check_entities(
                    entity.subunits, entity_variables_mapping
                )
                if not is_ovav:
                    return False
        return True

    return _check_entities(self.entity_pools)

is_submodel

is_submodel(other)

Return true if another given SBGN-PD model is a submodel of the SBGN-PD model, false otherwise

Source code in src/momapy/sbgn/pd.py
553
554
555
556
557
558
559
560
561
562
563
564
565
566
def is_submodel(self, other):
    """Return `true` if another given SBGN-PD model is a submodel of the SBGN-PD model, `false` otherwise"""
    return (
        self.entity_pools.issubset(other.entity_pools)
        and self.processes.issubset(other.processes)
        and self.compartments.issubset(other.compartments)
        and self.modulations.issubset(other.modulations)
        and self.logical_operators.issubset(other.logical_operators)
        and self.equivalence_operators.issubset(
            other.equivalence_operators
        )
        and self.submaps.issubset(other.submaps)
        and self.tags.issubset(other.tags)
    )

SBGNPDModelBuilder module-attribute

SBGNPDModelBuilder = get_or_make_builder_cls(SBGNPDModel)

Class for SBGN-PD model builders

SimpleChemical dataclass

SimpleChemical(
    *,
    id_: str = get_uuid4_as_str(),
    compartment: Compartment | None = None,
    label: str | None = None,
    state_variables: frozenset[StateVariable] = frozenset(),
    units_of_information: frozenset[
        UnitOfInformation
    ] = frozenset()
)

Bases: EntityPool

Class for simple chemical

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'dc37d284-6600-4ca9-930d-55dac4de01e4'
compartment Compartment | None
None
label str | None
None

SimpleChemicalLayout dataclass

SimpleChemicalLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 30.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 30.0
)

Bases: _SimpleMixin, SBGNNode

Class for simple chemical layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'3e281415-3d9c-4b5c-b2e3-11b577e4177f'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
30.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
30.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
791
792
793
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

SimpleChemicalMultimer dataclass

SimpleChemicalMultimer(
    *,
    id_: str = get_uuid4_as_str(),
    compartment: Compartment | None = None,
    label: str | None = None,
    state_variables: frozenset[StateVariable] = frozenset(),
    units_of_information: frozenset[
        UnitOfInformation
    ] = frozenset(),
    subunits: frozenset[Subunit] = frozenset(),
    cardinality: int | None = None
)

Bases: Multimer

Class for simple chemical multimers

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'ce3f4568-f6c3-4de7-8945-e375dd149da9'
compartment Compartment | None
None
label str | None
None
cardinality int | None
None

SimpleChemicalMultimerLayout dataclass

SimpleChemicalMultimerLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    offset: float = 3.0,
    subunits_stroke: (
        tuple[NoneValueType | Color] | None
    ) = None,
    subunits_stroke_width: (
        tuple[NoneValueType | float] | None
    ) = None,
    subunits_stroke_dasharray: (
        tuple[NoneValueType | tuple[float]] | None
    ) = None,
    subunits_stroke_dashoffset: tuple[float] | None = None,
    subunits_fill: (
        tuple[NoneValueType | Color] | None
    ) = None,
    subunits_transform: (
        tuple[NoneValueType | tuple[Transformation]] | None
    ) = None,
    subunits_filter: (
        tuple[NoneValueType | Filter] | None
    ) = None,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 30.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 30.0
)

Bases: _MultiMixin, SBGNNode

Class for simple chemical multimer layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'03e5361e-ac83-4fb8-a936-89505055bbff'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
30.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
30.0
offset float
3.0
subunits_stroke tuple[Union[NoneValueType, Color]] | None
None
subunits_stroke_width tuple[Union[NoneValueType, float]] | None
None
subunits_stroke_dasharray tuple[Union[NoneValueType, tuple[float]]] | None
None
subunits_stroke_dashoffset tuple[float] | None
None
subunits_fill tuple[Union[NoneValueType, Color]] | None
None
subunits_transform tuple[Union[NoneValueType, tuple[Transformation]]] | None
None
subunits_filter tuple[Union[NoneValueType, Filter]] | None
None

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

SimpleChemicalMultimerSubunit dataclass

SimpleChemicalMultimerSubunit(
    *,
    id_: str = get_uuid4_as_str(),
    label: str | None = None,
    state_variables: frozenset[StateVariable] = frozenset(),
    units_of_information: frozenset[
        UnitOfInformation
    ] = frozenset(),
    subunits: frozenset[Subunit] = frozenset(),
    cardinality: int | None = None
)

Bases: MultimerSubunit

Class for simple chemical multimer subunits

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'8a8e241d-aeae-4865-bace-9c2e4342ad8c'
label str | None
None
cardinality int | None
None

SimpleChemicalMultimerSubunitLayout dataclass

SimpleChemicalMultimerSubunitLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    offset: float = 3.0,
    subunits_stroke: (
        tuple[NoneValueType | Color] | None
    ) = None,
    subunits_stroke_width: (
        tuple[NoneValueType | float] | None
    ) = None,
    subunits_stroke_dasharray: (
        tuple[NoneValueType | tuple[float]] | None
    ) = None,
    subunits_stroke_dashoffset: tuple[float] | None = None,
    subunits_fill: (
        tuple[NoneValueType | Color] | None
    ) = None,
    subunits_transform: (
        tuple[NoneValueType | tuple[Transformation]] | None
    ) = None,
    subunits_filter: (
        tuple[NoneValueType | Filter] | None
    ) = None,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 30.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 60.0
)

Bases: _MultiMixin, SBGNNode

Class for simple chemical multimer subunit layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'21e212cf-5505-4d2f-a3f4-51b3ef25c2e6'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
30.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
60.0
offset float
3.0
subunits_stroke tuple[Union[NoneValueType, Color]] | None
None
subunits_stroke_width tuple[Union[NoneValueType, float]] | None
None
subunits_stroke_dasharray tuple[Union[NoneValueType, tuple[float]]] | None
None
subunits_stroke_dashoffset tuple[float] | None
None
subunits_fill tuple[Union[NoneValueType, Color]] | None
None
subunits_transform tuple[Union[NoneValueType, tuple[Transformation]]] | None
None
subunits_filter tuple[Union[NoneValueType, Filter]] | None
None

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

SimpleChemicalSubunit dataclass

SimpleChemicalSubunit(
    *,
    id_: str = get_uuid4_as_str(),
    label: str | None = None,
    state_variables: frozenset[StateVariable] = frozenset(),
    units_of_information: frozenset[
        UnitOfInformation
    ] = frozenset()
)

Bases: Subunit

Class for simple chemical subunits

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'f1c510a9-2a57-4c96-b562-fe7a286efb87'
label str | None
None

SimpleChemicalSubunitLayout dataclass

SimpleChemicalSubunitLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 30.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 30.0
)

Bases: _SimpleMixin, SBGNNode

Class for simple chemical subunit layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'291b4cb6-c41e-4d58-950a-980d80128455'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
30.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
30.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
791
792
793
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

StateVariable dataclass

StateVariable(
    *,
    id_: str = get_uuid4_as_str(),
    variable: str | None = None,
    value: str | None = None,
    order: int | None = None
)

Bases: SBGNAuxiliaryUnit

Class for state variables

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'632b5ec6-3617-4bff-b042-832bb3a2fe21'
variable str | None
None
value str | None
None
order int | None
None

StateVariableLayout dataclass

StateVariableLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 12.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 12.0
)

Bases: _SimpleMixin, SBGNNode

Class for state variable layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'75c7a0d2-6ade-4b34-bc3e-1721c0c5ffd1'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
12.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
12.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
791
792
793
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

Stimulation dataclass

Stimulation(
    *,
    id_: str = get_uuid4_as_str(),
    source: EntityPool | LogicalOperator,
    target: Process
)

Bases: Modulation

Class for stimulations

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'06355440-f229-43db-bd90-7f06f597ea9a'
source EntityPool | LogicalOperator
required
target Process
required

StimulationLayout dataclass

StimulationLayout(
    path_fill: NoneValueType | Color | None = NoneValue,
    path_stroke: NoneValueType | Color | None = black,
    path_stroke_width: float | None = 1.25,
    arrowhead_fill: NoneValueType | Color | None = white,
    arrowhead_stroke: NoneValueType | Color | None = black,
    arrowhead_stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    end_shorten: float = 0.0,
    fill: NoneValueType | Color | None = None,
    filter: NoneValueType | Filter | None = None,
    path_filter: NoneValueType | Filter | None = None,
    path_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    path_stroke_dashoffset: float | None = None,
    path_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    stroke: NoneValueType | Color | None = None,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    stroke_width: float | None = None,
    segments: tuple[
        Segment | BezierCurve | EllipticalArc
    ] = tuple(),
    source: LayoutElement | None = None,
    start_shorten: float = 0.0,
    target: LayoutElement | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    arrowhead_filter: NoneValueType | Filter | None = None,
    arrowhead_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    arrowhead_stroke_dashoffset: float | None = None,
    arrowhead_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    arrowhead_height: float = 10.0,
    arrowhead_width: float = 10.0
)

Bases: SBGNSingleHeadedArc

Class for stimulation layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'b9dce6e4-1bde-4ab6-928d-29b9fbcebab6'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
end_shorten float

The length the end of the arc will be shorten by

0.0
fill NoneValueType | Color | None

The fill color of the arc

None
filter NoneValueType | Filter | None

The fill filter of the arc

None
path_fill NoneValueType | Color | None
<momapy.drawing.NoneValueType object at 0x7f3954141040>
path_filter NoneValueType | Filter | None

The path filter of the arc

None
path_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
path_stroke_dasharray NoneValueType | tuple[float] | None

The path stroke dasharray of the arc

None
path_stroke_dashoffset float | None

The path stroke dashoffset of the arc

None
path_stroke_width float | None
1.25
path_transform NoneValueType | tuple[Transformation] | None

The path transform of the arc

None
stroke NoneValueType | Color | None

The stroke color of the arc

None
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the arc

None
stroke_dashoffset float | None

The stroke dashoffset of the arc

None
stroke_width float | None

The stroke width of the arc

None
segments tuple[Union[Segment, BezierCurve, EllipticalArc]]

The path segments of the arc

<dynamic>
source LayoutElement | None

The source of the arc

None
start_shorten float

The length the start of the arc will be shorten by

0.0
target LayoutElement | None

The target of the arc

None
transform NoneValueType | tuple[Transformation] | None

The transform of the arc

None
arrowhead_fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
arrowhead_filter NoneValueType | Filter | None

The arrowhead filter of the arc

None
arrowhead_stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
arrowhead_stroke_dasharray NoneValueType | tuple[float] | None

The arrowhead stroke dasharray of the arc

None
arrowhead_stroke_dashoffset float | None

The arrowhead stroke dashoffset of the arc

None
arrowhead_stroke_width float | None
1.25
arrowhead_transform NoneValueType | tuple[Transformation] | None

The arrowhead transform of the arc

None
arrowhead_height float
10.0
arrowhead_width float
10.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

arrowhead_base

Return the arrowhead base anchor point of the single-headed arc

arrowhead_bbox

Return the bounding box of the single-headed arc arrowhead

arrowhead_border

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.

arrowhead_drawing_elements

Return the drawing elements of the single-headed arc arrowhead

arrowhead_length

Return the length of the single-headed arc arrowhead

arrowhead_tip

Return the arrowhead tip anchor point of the single-headed arc

bbox

Compute and return the bounding box of the layout element

childless

Return a copy of the arc with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

end_point

Return the ending point of the arc

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

fraction

Return the position and angle on the arc at a given fraction (of the total arc length)

length

Return the total length of the arc path

path_drawing_elements

Return the drawing elements of the single-headed arc path

points

Return the points of the arc path

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_children

Return the self children of the arc

self_drawing_elements

Return the self drawing elements of the single-headed arc

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

start_point

Return the starting point of the arc

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

arrowhead_base

arrowhead_base() -> Point

Return the arrowhead base anchor point of the single-headed arc

Source code in src/momapy/core.py
1089
1090
1091
1092
1093
1094
1095
1096
1097
def arrowhead_base(self) -> momapy.geometry.Point:
    """Return the arrowhead base anchor point of the single-headed arc"""
    arrowhead_length = self.arrowhead_length()
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return self.arrowhead_tip() - (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.end_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

arrowhead_bbox

arrowhead_bbox() -> Bbox

Return the bounding box of the single-headed arc arrowhead

Source code in src/momapy/core.py
1099
1100
1101
1102
1103
def arrowhead_bbox(self) -> momapy.geometry.Bbox:
    """Return the bounding box of the single-headed arc arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.arrowhead_drawing_elements()
    )

arrowhead_border

arrowhead_border(point) -> Point

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
def arrowhead_border(self, point) -> momapy.geometry.Point:
    """Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """

    point = momapy.drawing.get_drawing_elements_border(
        self.arrowhead_drawing_elements(), point
    )
    if point is None:
        return self.arrowhead_tip()
    return point

arrowhead_drawing_elements

arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the single-headed arc arrowhead

Source code in src/momapy/core.py
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
def arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the single-headed arc arrowhead"""
    elements = self._arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_arrowhead",
        elements=elements,
        fill=self.arrowhead_fill,
        filter=self.arrowhead_filter,
        id_=f"{self.id_}_arrowhead",
        stroke=self.arrowhead_stroke,
        stroke_dasharray=self.arrowhead_stroke_dasharray,
        stroke_dashoffset=self.arrowhead_stroke_dashoffset,
        stroke_width=self.arrowhead_stroke_width,
        transform=self.arrowhead_transform,
    )
    transformation = self._get_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

arrowhead_length

arrowhead_length() -> float

Return the length of the single-headed arc arrowhead

Source code in src/momapy/core.py
1071
1072
1073
1074
1075
1076
1077
1078
def arrowhead_length(self) -> float:
    """Return the length of the single-headed arc arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return bbox.east().x

arrowhead_tip

arrowhead_tip() -> Point

Return the arrowhead tip anchor point of the single-headed arc

Source code in src/momapy/core.py
1080
1081
1082
1083
1084
1085
1086
1087
def arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the arrowhead tip anchor point of the single-headed arc"""
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.end_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

childless

childless() -> Self

Return a copy of the arc with no children

Source code in src/momapy/core.py
978
979
980
def childless(self) -> typing.Self:
    """Return a copy of the arc with no children"""
    return dataclasses.replace(self, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

end_point

end_point() -> Point

Return the ending point of the arc

Source code in src/momapy/core.py
974
975
976
def end_point(self) -> momapy.geometry.Point:
    """Return the ending point of the arc"""
    return self.points()[-1]

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

fraction

fraction(fraction: float) -> tuple[Point, float]

Return the position and angle on the arc at a given fraction (of the total arc length)

Source code in src/momapy/core.py
982
983
984
985
986
987
988
989
990
991
def fraction(self, fraction: float) -> tuple[momapy.geometry.Point, float]:
    """Return the position and angle on the arc at a given fraction (of the total arc length)"""
    current_length = 0
    length_to_reach = fraction * self.length()
    for segment in self.segments:
        current_length += segment.length()
        if current_length >= length_to_reach:
            break
    position, angle = segment.get_position_and_angle_at_fraction(fraction)
    return position, angle

length

length()

Return the total length of the arc path

Source code in src/momapy/core.py
966
967
968
def length(self):
    """Return the total length of the arc path"""
    return sum([segment.length() for segment in self.segments])

path_drawing_elements

path_drawing_elements() -> list[Path]

Return the drawing elements of the single-headed arc path

Source code in src/momapy/core.py
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
def path_drawing_elements(self) -> list[momapy.drawing.Path]:
    """Return the drawing elements of the single-headed arc path"""
    arrowhead_length = self.arrowhead_length()
    if len(self.segments) == 1:
        segment = (
            self.segments[0]
            .shortened(self.start_shorten, "start")
            .shortened(self.end_shorten + arrowhead_length, "end")
        )
        actions = [
            momapy.drawing.MoveTo(segment.p1),
            self._make_path_action_from_segment(segment),
        ]
    else:
        first_segment = self.segments[0].shortened(
            self.start_shorten, "start"
        )
        last_segment = self.segments[-1].shortened(
            self.end_shorten + arrowhead_length, "end"
        )
        actions = [
            momapy.drawing.MoveTo(first_segment.p1),
            self._make_path_action_from_segment(first_segment),
        ]
        for segment in self.segments[1:-1]:
            action = self._make_path_action_from_segment(segment)
            actions.append(action)
        actions.append(self._make_path_action_from_segment(last_segment))
    path = momapy.drawing.Path(
        actions=actions,
        class_=f"{type(self).__name__}_path",
        fill=self.path_fill,
        filter=self.path_filter,
        id_=f"{self.id_}_path",
        stroke=self.path_stroke,
        stroke_dasharray=self.path_stroke_dasharray,
        stroke_dashoffset=self.path_stroke_dashoffset,
        stroke_width=self.path_stroke_width,
        transform=self.path_transform,
    )
    return [path]

points

points() -> list[Point]

Return the points of the arc path

Source code in src/momapy/core.py
958
959
960
961
962
963
964
def points(self) -> list[momapy.geometry.Point]:
    """Return the points of the arc path"""
    points = []
    for segment in self.segments:
        points.append(segment.p1)
    points.append(segment.p2)
    return points

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_children

self_children() -> list[LayoutElement]

Return the self children of the arc

Source code in src/momapy/core.py
954
955
956
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the arc"""
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the single-headed arc

Source code in src/momapy/core.py
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the single-headed arc"""
    elements = (
        self.path_drawing_elements() + self.arrowhead_drawing_elements()
    )
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

start_point

start_point() -> Point

Return the starting point of the arc

Source code in src/momapy/core.py
970
971
972
def start_point(self) -> momapy.geometry.Point:
    """Return the starting point of the arc"""
    return self.points()[0]

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

StoichiometricProcess dataclass

StoichiometricProcess(
    *,
    id_: str = get_uuid4_as_str(),
    reactants: frozenset[Reactant] = frozenset(),
    products: frozenset[Product] = frozenset(),
    reversible: bool = False
)

Bases: Process

Base class for stoichiometric processes

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'b051d98f-fade-479c-b6c5-507e0671c70f'
reversible bool
False

Submap dataclass

Submap(
    *,
    id_: str = get_uuid4_as_str(),
    label: str | None = None,
    terminals: frozenset[Terminal] = frozenset()
)

Bases: SBGNModelElement

Class for submaps

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'512ced33-e625-4507-8916-cb05ef6f7558'
label str | None
None

SubmapLayout dataclass

SubmapLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 80.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    stroke_width: float = 2.25,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 80.0
)

Bases: _SimpleMixin, SBGNNode

Class for submap layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'150350f5-766e-477d-9edc-d87809e45098'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
80.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float
2.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
80.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
791
792
793
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

Subunit dataclass

Subunit(
    *,
    id_: str = get_uuid4_as_str(),
    label: str | None = None
)

Bases: SBGNAuxiliaryUnit

Base class for subunits

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'e1b51bf3-36f8-4c01-9acc-140a74d0f58b'
label str | None
None

Tag dataclass

Tag(
    *,
    id_: str = get_uuid4_as_str(),
    label: str | None = None,
    reference: TagReference | None = None
)

Bases: SBGNModelElement

Class for tags

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'6565fa6f-d2bb-4259-a0eb-17092dbf6974'
label str | None
None
reference TagReference | None
None

TagLayout dataclass

TagLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 35.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 35.0,
    direction: Direction = RIGHT,
    angle: float = 70.0
)

Bases: _SimpleMixin, SBGNNode

Class for tag layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'8cf899be-4a63-447d-9693-98993f67e034'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
35.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
35.0
direction Direction
<Direction.RIGHT: 4>
angle float
70.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
angle float

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle class-attribute instance-attribute

angle: float = 70.0

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
791
792
793
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

TagReference dataclass

TagReference(
    *,
    id_: str = get_uuid4_as_str(),
    element: EntityPool | Compartment
)

Bases: SBGNRole

Class for tag references

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'ad3901a3-d865-4474-ad68-9ce61c950c91'
element EntityPool | Compartment
required

Terminal dataclass

Terminal(
    *,
    id_: str = get_uuid4_as_str(),
    label: str | None = None,
    reference: TerminalReference | None = None
)

Bases: SBGNAuxiliaryUnit

Class for terminals

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'a7c7d16f-5de3-41f0-ae8d-288badaf08fa'
label str | None
None
reference TerminalReference | None
None

TerminalLayout dataclass

TerminalLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 35.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 35.0,
    direction: Direction = RIGHT,
    angle: float = 70.0
)

Bases: _SimpleMixin, SBGNNode

Class for terminal layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'3577cca9-036b-4791-8b00-572785efdda6'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
35.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
35.0
direction Direction
<Direction.RIGHT: 4>
angle float
70.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
angle float

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle class-attribute instance-attribute

angle: float = 70.0

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
791
792
793
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

TerminalReference dataclass

TerminalReference(
    *,
    id_: str = get_uuid4_as_str(),
    element: EntityPool | Compartment
)

Bases: SBGNRole

Class for terminal references

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'ec3bf6c6-9333-474b-b6b9-e5d1ca8c08dd'
element EntityPool | Compartment
required

UncertainProcess dataclass

UncertainProcess(
    *,
    id_: str = get_uuid4_as_str(),
    reactants: frozenset[Reactant] = frozenset(),
    products: frozenset[Product] = frozenset(),
    reversible: bool = False
)

Bases: StoichiometricProcess

Class for uncertain processes

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'e32eb439-370f-4d23-a675-3707342480df'
reversible bool
False

UncertainProcessLayout dataclass

UncertainProcessLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 20.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 20.0,
    direction: Direction = HORIZONTAL,
    left_to_right: bool = True,
    left_connector_length: float = 10.0,
    right_connector_length: float = 10.0,
    left_connector_stroke: (
        NoneValueType | Color | None
    ) = None,
    left_connector_stroke_width: float | None = None,
    left_connector_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    left_connector_stroke_dashoffset: float | None = None,
    left_connector_fill: (
        NoneValueType | Color | None
    ) = None,
    left_connector_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    left_connector_filter: (
        NoneValueType | Filter | None
    ) = None,
    right_connector_stroke: (
        NoneValueType | Color | None
    ) = None,
    right_connector_stroke_width: float | None = None,
    right_connector_stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    right_connector_stroke_dashoffset: float | None = None,
    right_connector_fill: (
        NoneValueType | Color | None
    ) = None,
    right_connector_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    right_connector_filter: (
        NoneValueType | Filter | None
    ) = None
)

Bases: _ConnectorsMixin, _SimpleMixin, _TextMixin, SBGNNode

Class for uncertain process layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'c8090a9e-3a93-44f6-963e-3a826bdef772'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
20.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
20.0
direction Direction
<Direction.HORIZONTAL: 1>
left_to_right bool
True
left_connector_length float
10.0
right_connector_length float
10.0
left_connector_stroke NoneValueType | Color | None
None
left_connector_stroke_width float | None
None
left_connector_stroke_dasharray NoneValueType | tuple[float] | None
None
left_connector_stroke_dashoffset float | None
None
left_connector_fill NoneValueType | Color | None
None
left_connector_transform NoneValueType | tuple[Transformation] | None
None
left_connector_filter NoneValueType | Filter | None
None
right_connector_stroke NoneValueType | Color | None
None
right_connector_stroke_width float | None
None
right_connector_stroke_dasharray NoneValueType | tuple[float] | None
None
right_connector_stroke_dashoffset float | None
None
right_connector_fill NoneValueType | Color | None
None
right_connector_transform NoneValueType | tuple[Transformation] | None
None
right_connector_filter NoneValueType | Filter | None
None

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
791
792
793
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

UnitOfInformation dataclass

UnitOfInformation(
    *,
    id_: str = get_uuid4_as_str(),
    value: str,
    prefix: str | None = None
)

Bases: SBGNAuxiliaryUnit

Class for units of information

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'0cef4ab4-be0c-4244-a601-84a89dac311c'
value str
required
prefix str | None
None

UnitOfInformationLayout dataclass

UnitOfInformationLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 12.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 12.0
)

Bases: _SimpleMixin, SBGNNode

Class for unit of information layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'6318b7d1-7886-41a7-8607-f4dd0f115201'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
12.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
12.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
791
792
793
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

UnspecifiedEntity dataclass

UnspecifiedEntity(
    *,
    id_: str = get_uuid4_as_str(),
    compartment: Compartment | None = None,
    label: str | None = None
)

Bases: EntityPool

Class for unspecified entities

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'9372975d-a7fb-4862-a3ac-1702fe1e7728'
compartment Compartment | None
None
label str | None
None

UnspecifiedEntityLayout dataclass

UnspecifiedEntityLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 30.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 60.0
)

Bases: _SimpleMixin, SBGNNode

Class for unspecified entity layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'261213a8-86b2-49ac-a3b8-72af38f2aba5'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
30.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
60.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
791
792
793
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

UnspecifiedEntitySubunit dataclass

UnspecifiedEntitySubunit(
    *,
    id_: str = get_uuid4_as_str(),
    label: str | None = None
)

Bases: Subunit

Class for unspecified entity subunits

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'3a132216-ff1a-4d74-9f62-3456b17191f2'
label str | None
None

UnspecifiedEntitySubunitLayout dataclass

UnspecifiedEntitySubunitLayout(
    fill: NoneValueType | Color | None = white,
    stroke: NoneValueType | Color | None = black,
    stroke_width: float | None = 1.25,
    *,
    id_: str = get_uuid4_as_str(),
    layout_elements: tuple[LayoutElement] = tuple(),
    group_fill: NoneValueType | Color | None = None,
    group_fill_rule: FillRule | None = None,
    group_filter: NoneValueType | Filter | None = None,
    group_font_family: str | None = None,
    group_font_size: float | None = None,
    group_font_style: FontStyle | None = None,
    group_font_weight: FontWeight | float | None = None,
    group_stroke: NoneValueType | Color | None = None,
    group_stroke_dasharray: tuple[float] | None = None,
    group_stroke_dashoffset: float | None = None,
    group_stroke_width: float | None = None,
    group_text_anchor: TextAnchor | None = None,
    group_transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    filter: NoneValueType | Filter | None = None,
    height: float = 30.0,
    label: TextLayout | None = None,
    position: Point,
    stroke_dasharray: (
        NoneValueType | tuple[float] | None
    ) = None,
    stroke_dashoffset: float | None = None,
    transform: (
        NoneValueType | tuple[Transformation] | None
    ) = None,
    width: float = 60.0
)

Bases: _SimpleMixin, SBGNNode

Class for unspecified entity subunit layouts

Parameters:

Name Type Description Default
id_ str

The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element

'430f5f99-fe2e-419b-8a83-93495101e787'
layout_elements tuple[LayoutElement]

The sub-layout elements of the group layout. These are part of the children of the group layout

<dynamic>
group_fill NoneValueType | Color | None

The fill color of the group layout

None
group_fill_rule FillRule | None

The fill rule of the group layout

None
group_filter NoneValueType | Filter | None

The filter of the group layout

None
group_font_family str | None

The font family of the group layout

None
group_font_size float | None

The font size of the group layout

None
group_font_style FontStyle | None

The font style of the group layout

None
group_font_weight FontWeight | float | None

The font weight of the group layout

None
group_stroke NoneValueType | Color | None

The stroke color of the group layout

None
group_stroke_dasharray tuple[float] | None

The stroke dasharray of the group layout

None
group_stroke_dashoffset float | None

The stroke dashoffset of the group layout

None
group_stroke_width float | None

The stroke width of the group layout

None
group_text_anchor TextAnchor | None

The text anchor of the group layout

None
group_transform NoneValueType | tuple[Transformation] | None

The transform of the group layout

None
fill NoneValueType | Color | None
Color(red=255, green=255, blue=255, alpha=1.0)
filter NoneValueType | Filter | None

The filter of the node

None
height float
30.0
label TextLayout | None

The label of the node

None
position Point

The position of the node

required
stroke NoneValueType | Color | None
Color(red=0, green=0, blue=0, alpha=1.0)
stroke_dasharray NoneValueType | tuple[float] | None

The stroke dasharray of the node

None
stroke_dashoffset float | None

The stroke dashoffset of the node

None
stroke_width float | None
1.25
transform NoneValueType | tuple[Transformation] | None

The transform of the node

None
width float
60.0

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the self drawing elements of the node

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
135
136
137
def anchor_point(self, anchor_name) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
830
831
832
833
834
835
836
837
838
839
840
841
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the layout element

Source code in src/momapy/core.py
73
74
75
76
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the layout element"""
    bounds = self.to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
807
808
809
810
811
812
813
814
815
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
787
788
789
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
843
844
845
def childless(self) -> typing.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
573
574
575
576
577
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
120
121
122
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
93
94
95
96
97
98
99
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=drawing_elements,
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
719
720
721
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
711
712
713
714
715
716
717
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
723
724
725
726
727
728
729
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other, flattened=False, unordered=False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
108
109
110
111
112
113
114
115
116
117
118
def equals(self, other, flattened=False, unordered=False) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
101
102
103
104
105
106
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
791
792
793
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
691
692
693
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
703
704
705
706
707
708
709
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
695
696
697
698
699
700
701
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
683
684
685
686
687
688
689
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
675
676
677
678
679
680
681
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(
    angle: float,
    unit: Literal["degrees", "radians"] = "degrees",
) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
817
818
819
820
821
822
823
824
825
826
827
828
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
530
531
532
533
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
795
796
797
798
799
800
801
802
803
804
805
def self_border(
    self, point: momapy.geometry.Point
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
665
666
667
668
669
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the node

Source code in src/momapy/core.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the node"""
    elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=elements,
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
524
525
526
527
528
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(
        self.drawing_elements()
    )

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
671
672
673
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
747
748
749
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
731
732
733
734
735
736
737
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
739
740
741
742
743
744
745
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
751
752
753
754
755
756
757
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
759
760
761
762
763
764
765
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
124
125
126
127
128
129
130
131
132
133
def to_shapely(
    self, to_polygons: bool = False
) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(
            to_polygons=to_polygons
        ).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
775
776
777
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
779
780
781
782
783
784
785
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
767
768
769
770
771
772
773
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node